0

I am working with a jax-rs rest service.

Is there a best practice for how to specify null values in a REST GET request.

E.g. if I have an address resource that contains addresses that can have null values in streetNumber. And I have an endpoint

 ../address?streetName=foostreet

which gives me multiple hits in the response out of which one has a null value in the field.

How do I design an api that lets me search for this particular address, without introducing magic stringvalues like "NULL" or "EMPTY" that are to be parsed on the server as null.

Manolo
  • 1,597
  • 4
  • 21
  • 35
  • 1
    I do not know if there are better solutions, but by not sending the query string at all should yield null. Or, maybe this will help: https://stackoverflow.com/questions/31254490/how-to-send-null-in-http-query-string – ionizer Jan 08 '20 at 08:15
  • Right, not sending a query param at all yields null, but that case should be reserved for the absence of a query criteria on that field. I.e. null OR any value should match. – Manolo Jan 08 '20 at 13:11

0 Answers0