问题
I'm trying to create a new "incident" (case) in by Dynamics 365 instance via the Web API.
In my http request, I don't know which field are mandatory. I tried to only add the title, subject, and customer, but I have a Http 400 error back...
I'm using Postman do try my Http Request. If I send the following json
{
"title": "Case created from Web api",
"_customerid_value": "bb2b6a80-7102-e711-8101-3993bb354ff0"
}
But I had the error: "CRM do not support direct update of Entity Reference properties, Use Navigation properties instead."
So I tried to user the @data.bind trick (https://msdn.microsoft.com/en-us/library/gg328090.aspx#Anchor_3)
{
"title": "Case created from Web api",
"customerid@odata.bind": "/contacts(bb2b6a80-7102-e711-8101-3993bb354ff0)"
}
I get the following error: "An undeclared property 'customerid' 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."
So now I don't really now how to do it. Can we create a incident (in my case a "service Case") through the Web API ?
Thank you
回答1:
Found the solution. Just need to add "_contact" to the @odata instance.
{
"title": "Case created from Web api",
"customerid_contact@odata.bind": "/contacts(bb2b6a80-7102-e711-8101-3993bb354ff0)"
}
来源:https://stackoverflow.com/questions/42631164/microsoft-dynamics-web-api