I have an old WCF service that has worked for many years. Now I needed to make a small change (add 2 fields) in the data the service returns. Suddenly the service run on Postman returns a 400 Bad Request error:
The server encountered an error processing the request. The exception message is 'The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'GetProducts'. The data at the root level is invalid. Line 1, position 1.'.
Here is the request body: {"APIKey":"14a6bc29-b0be-1234-65u8-fefc6feb0547","ItemSKUs":["0254-0030-21"],"CustomerNumber":233125,"EffectiveDate":"/Date(1670168350000)/","BranchNumber":100,"SessionID":""}
I can't figure out what can be wrong about this data.
In general, HTTP 400 errors can occur for the following reasons:
Since your service was previously running successfully. When you add two new fields, an error is generated. You can see if the entity classes in the foreground and back are consistent.
Similarly, maybe your newly added field did not capture it as JSON, you can convert the newly added field to JSON to continue the transfer.