JSON REST Program "Unable to deserialize entity"

Hello. We have created a json REST program to create a sales order and are encountering the following error: “Unable to deserialize entity”.
We are able to run a GET to pull an existing sales order without a problem. We can also even run a POST with the same info from that existing sales order, just setting the OrderNum to 0 and changing the PO # and it works and creates a new sales order. However, each time we try a brand new POST with different data (custnum, dates, etc), we get the error above. How do we troubleshoot this? Is there any documentation on exactly which fields are required?
Thanks, Sharla


This error is shown when you pass invalid data type for some field. Most commonly when passing invalid date.

These are valid:

"OrderDate": "2022-04-01T00:00:00+01:00"
"OrderDate": "2022-04-01"
"OrderDate": null

These not (empty string is not valid):

"OrderDate": "2022/04/01"
"OrderDate": ""

Validate other fields as well. For example CustNum is an int, passing it as a string will result in the same error - “Unable to deserialize entity”.

1 Like

I have the following fields populated when adding a Sales Order header, may not all be required but a reasonable starting point.
Company, CustNum, TermsCode, BTCustNum,ShipToCustNum, PONum, ShipViaCode, ShipToNum, TaxRegionCode, SalesRepCode1, RepSplit1, ExpirationMonth, EpirationYear, Plant, OrderComment and FOB


Thank you both for the replies! A couple days ago we found that we needed to populate BTCustNum. We were thinking it would just default to the same value as CustNum, but it did not. Once we populated that field, it worked. It seems like the minimum required fields (like Mark has above) for this API to work would be listed somewhere, but instead it seems like tribal knowledge…
Thanks again!

All is revealed in the trace. After all, we are trying to mimic what the client does. Anything the client does, we need to do too. There are many examples of people on this list struggling to figure out the API. Those who start with a trace have a much easier time of it.