Microsoft Dynamics - Web API

与世无争的帅哥 提交于 2019-12-12 20:58:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!