Recently working on Dynamics 365 V8.2 environment, I faced “Bad Request” error in my create request and while I tried to debug the code, I found error:
“An undeclared property ‘him_supplierid’ which only has property annotations in the payload but no property value was found in the payload. In OData, only declared navigation properties and declared named streams can be represented as properties without values…..”
But I was sure that I am using correct field name and syntax for setting single-valued navigation using Web API. But we I tried the same code in my demo environment with Dynamics 365 9.0, it worked fine without any issue.
When I did some research on the this error, I found this is a known issue for V 8.2 Web API request. In case if you are working with Dynamics 365 V 8.2, you need to use schema name of the lookup field instead of the logical name. When I changed single-values property logical name with schema name like below, it worked perfectly.
//you can find schema name of the field under field explorer entity["him_SupplierId@odata.bind"] = "/accounts("+supplierid+")"; //use schema name here
Hope it will help someone !!