Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Unanswered

Contact creation error with binding to entity id

Posted on by
I have a Dynamics CRM instance that I am initially successfully accessing via Postman.
This is v9.0

I have a POST request which creates a new contact at: /api/data/v9.0/contacts

{
    /customertypecode/: 127840004,
    /xx_contractorstatus/: 127840000,
    /firstname/: /Wallie/,
    /lastname/: /Worker1-7/,
    /fullname/: /Wallie Worker/,
    /emailaddress1/: /wworker1@test.com/
}

I also have a custom list of nationalities at: /api/data/v9.0/xx_nationalities

The structure of xx_nationalities is:

​​​{
    /@odata.context/: https://xxdev.api.[HIDDEN].dynamics.com/api/data/v9.0/$metadata#xx_nationalities/,
    /value/: [
        {
            /@odata.etag/: /W////35347625////,
            /_organizationid_value/: /6b47908f-b289-4601-b80c-59667d32deda/,
            /xx_sharecoderequired/: true,
            /xx_nationalityid/: /297db2c4-15a3-ed11-aad1-0022484257f7/,
            /xx_name/: /Afghan/,
            /xx_wrsregistrationrequired/: false,
            /xx_visarequired/: true,
            /statuscode/: 1,
            /importsequencenumber/: 20,
            /_createdby_value/: /2c738c48-4115-ec11-b6e6-002248412237/,
            /modifiedon/: /2023-02-02T16:22:38Z/,
            /xx_brprequired/: true,
            /_modifiedby_value/: /2c738c48-4115-ec11-b6e6-002248412237/,
            /versionnumber/: 35347625,
            /createdon/: /2023-02-02T16:22:38Z/,
            /statecode/: 0,
            /overriddencreatedon/: null,
            /_modifiedonbehalfby_value/: null,
            /xx_nationalityfullname/: null,
            /utcconversiontimezonecode/: null,
            /_createdonbehalfby_value/: null,
            /xx_iseu/: null,
            /timezoneruleversionnumber/: null
        }
    ]
}

I need to attach a nationality to the contact upon Contact creation but am getting errors. When xx_nationality is returned within a Contact GET it is named as:
/_xx_nationality_value/: /5f7db2c4-15a3-ed11-aad1-0022484257f7/
 
I have tried direct to returned value, with id, using @odata.bind, with entity wrapping and with. / without slash in value and underscore in property. But nothing seems to work.
/_xx_nationality_value/: /5f7db2c4-15a3-ed11-aad1-0022484257f7/
error: CRM do not support direct update of Entity Reference properties, Use Navigation properties instead
 
/_xx_nationality_value@odata.bind/: //xx_nationalities(5f7db2c4-15a3-ed11-aad1-0022484257f7)/
/xx_nationalityid@odata.bind/: //xx_nationalities(5f7db2c4-15a3-ed11-aad1-0022484257f7)/
/xx_nationalityid_nationalities@odata.bind/: /xx_nationalities(5f7db2c4-15a3-ed11-aad1-0022484257f7)/
/xx_nationalityid_nationalities@odata.bind/: //xx_nationalities(5f7db2c4-15a3-ed11-aad1-0022484257f7)/
 
error: Microsoft.OData.ODataException: An undeclared property '_xx_nationalityid_nationalities' which only has property annotations in the payload but no property value was found in the payload
 
This seems to be something which is probably obvious but this is our first excursion into hitting the CRM and we can't find a solution within the docs and unfortunately we can't download the /api/data/v9.0/$metadata file as its too large to browser or Postman.

My suspician is that because our CRM is setup to use //xx_nationalities/ instead of //nationalities/ that this is screwing around the solution of how to target.

I.e. instead of [property]_[entitycollection] eg nationalityid_nationality@odata.bind
we're trying something more like:
xx_nationalityid_xx_nationality@odata.bind

But maybe the singular does work with the prepending xx.

Any help gratefully received!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans