简体   繁体   中英

Microsoft Dynamics crm api-Create contact under account

Trying to create contact in Microsoft Dynamics crm using api.

The request url is https://alliedmodulartemp.api.crm.dynamics.com/api/data/v9.1/contacts

While creating contact want to set the contact under account (ie) want to set _parentcustomerid_value.

Tried using the following formats:

URL:https://alliedmodulartemp.api.crm.dynamics.com/api/data/v9.1/contacts(POST)
input:
{
  "firstname":"alrinmyjammy",
 "emailaddress1":"leonmyjamkutty@gmail.com",
 "_parentcustomerid_value@odata.bind": "/accounts(a5f68843-ec4b-ea11-a812-000d3a579ca8)"

 }
input:
{
  "firstname":"alrinmyjammy",
 "emailaddress1":"leonmyjamkutty@gmail.com",
 "parentcustomerid@odata.bind": "/accounts(a5f68843-ec4b-ea11-a812-000d3a579ca8)"

 }

But the error is,

An error occurred while validating input parameters: Microsoft.OData.ODataException: A property '_parentcustomerid_value' which only has property annotations in the payload but no property value is declared to be of type 'Edm.Guid'. In OData, only navigation properties and named streams can be represented as properties without values.

Your body should be like below. I just tested with one of my CRM instance and worked fine for me. url is correct https://alliedmodulartemp.api.crm.dynamics.com/api/data/v9.1/contacts

{
    "firstname": "Test 2 Postman",
    "lastname": "Test 2 Postman",
    "parentcustomerid_account@odata.bind":"/accounts(22B474B7-4F44-E111-8C06-1CC1DEE8BACD)"
} 

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