Home > OS >  How can i set a null value in json body to update a database table?
How can i set a null value in json body to update a database table?

Time:10-31

I am call an endpoint wit a json body as follow :

{
 "OrderId": 123,
 "OrderItem": 100,
 "OrderAmount": null,
}

The endpoint is called , but the OrderAmount column in the db is not set to NULL. The column is of type (int, null) How can i set the value in the db to NULL from the json body ?

CodePudding user response:

Is your OrderAmount in your database set to NULL, when you created the table? usually if column type is INT, then it will be set to 0 instead of null. you need to change type to VARCHAR.

try pass an empty String "", and see what happens?

  • Related