✅ Pattern for PATCH API Parameter Existence Check
[ASP Core 8, .NET 8]
I am developing some PATCH endpoints to update existing objects. I want my endpoint to only modify properties of the object that were set in the request - but null can only be a valid value to set.
My problem seems to be that if I pass a URL parameter or payload with a parameter set, but it is blank, ASP is saying it is null. For example
With a payload
Then I would expect a blank string
What pattern should I develop to make a proper PATCH endpoint that only utilizes parameters actually set in the payload?
I am developing some PATCH endpoints to update existing objects. I want my endpoint to only modify properties of the object that were set in the request - but null can only be a valid value to set.
My problem seems to be that if I pass a URL parameter or payload with a parameter set, but it is blank, ASP is saying it is null. For example
With a payload
Then I would expect a blank string
"". Instead, ASP gives me null.What pattern should I develop to make a proper PATCH endpoint that only utilizes parameters actually set in the payload?