Issue with handling nullable fields in REST API Resource with form data

I am currently working with a REST API resource that uses form data content type, as file upload is required in this API call. The API includes some nullable fields. However, I am facing an issue as I don't see an option to explicitly set null values for keys or skip these keys entirely from the payload.

I have attempted using a blank string, but it seems not to be treated as a null value. Could you please provide guidance on how to handle nullable fields in this scenario?


[Price is nullable field in this case]

I think if you return undefined in the value, it'll be omittied

{{ optionForm.data.price ? optionForm.data.price : undefined }}
1 Like

@Harry_Doan How can we send null value for a field? It's required to set a field to null for resetting it in update resource query. If we set it to undefined, it omits the key from the payload.

@Neeraj_Gahlot I think you can use "null" string or "" empty string? It depends on your server and how it interpret "null" values. We're not opinionated about it.

We ended up passing "" empty string for this field. and, then accordingly changed logic on the server side.

1 Like