1. S&F Datentechnik
  2. SnapDevelop
  3. Monday, 5 December 2022 14:02 PM UTC


I'm wondering how to handle update requests in my API, where the request does not necessarily include all the properties that the API is able to update.
The API might be able to receive a DTO with 10 properties, but if your JSON only contains 5 of those, the remaining ones will be considered null.
This might lead to null being written into the database, even though the property wasn't actually present in the request and not supposed to be changed at all.
Generally though, actually passing a property with null as its value is absolutely fine and should be updated accordingly.

So the main question is, how to differentiate between null values and not present values?


Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Monday, 5 December 2022 14:53 PM UTC
  2. SnapDevelop
  3. # 1

Hi Chris,

There's a couple of ways I would go about this:

  1.  Instead of sending an entire DTO from the client, generate a PATCH document
  2.  In the client app, instead of sending a null, send an empty string "" where applicable. Then, in the Web API, you compare against string.Empty to know if you should ignore or save the property
  3.  In the model class, assign a default value to the properties that is unlikely to be used by the customers. Then when the request comes in, if the property has this value it means it wasn't set

Hope this helps!


  1. Logan Liu @Appeon
  2. Tuesday, 6 December 2022 06:01 AM UTC
Hi Chris,

You can also refer to a similar topic here:


Regards, Logan
  1. Helpful
There are no comments made yet.
  • Page :
  • 1

There are no replies made for this question yet.
However, you are not allowed to reply to this question.