简体   繁体   中英

Microsoft Dynamics - Web API

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

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)"
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM