Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Using NEST Web API with C# to associate Account With Contact

(0) ShareShare
ReportReport
Posted on by 10

I am trying to use C# and the NEXT Web API set for CRM to populate data into CRM.

currently I can add Accounts and Contacts with no issues.

I am having issues trying to find an example of how to associate the account entity with the contact entity.

I have tried both POST & PATCH but keep on getting "BadRequest"

createRequest2 = {Method: PATCH, RequestUri: 'xxxxxxxxxxxxx.api.crm.dynamics.com/.../$ref', Version: 1.1, Content: System.Net.Http.StringContent, Headers:
{
Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: application/json; charset=utf-8
Content-Length: 127
}}

{{
"@odata.id": " ">xxxxxxxxxxxxx.api.crm.dynamics.com/.../accounts(6314b517-a25b-462c-9c63-1b87947fd2f4)"
}}

httpClient.Send(createRequest2);

is there anyplace where I can get more detailed examples in c# that work with the CRM NEST Web API?

  • a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: Using NEST Web API with C# to associate Account With Contact

    Hello,

    If my reply (or replies) answers your question take a minute and verify the answer. You can do it by clicking "Yes" at the top of the reply (or replies) under the label "Does this answer your question?"

  • mark66221 Profile Picture
    mark66221 10 on at
    RE: Using NEST Web API with C# to associate Account With Contact

    Thank you that gives me some insight

  • Verified answer
    a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: Using NEST Web API with C# to associate Account With Contact

    You can check xxx.crm.dynamics.com/.../$metadata

  • mark66221 Profile Picture
    mark66221 10 on at
    RE: Using NEST Web API with C# to associate Account With Contact

    I have gotten the following working:

    {xxxxxxxxxxxxx.api.crm.dynamics.com/.../$ref}

    with a body of:

    {"@odata.id": "xxxxxxxxxxx.api.crm.dynamics.com/.../contacts(fcfbf1e0-dbc3-eb11-bacc-000d3a9e1499)"}

    What I really need at this time is a place to find a list and descriptions of the different "contact_customer_accounts" so I can plan what needs to be done.

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: Using NEST Web API with C# to associate Account With Contact

    Hello Mark,

    What relation do you want to set? PrimaryContact field on the account or customerid field on the contact? Or something else?

    My usual goto in this case is CrmRestBuilder - github.com/.../2.6.0.0

    Just install the tool to the Dataverse instance and let the tool do the remaining things.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,321 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans