web
You’re offline. This is a read only version of the page.
close
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?

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    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.

  • mark66221 Profile Picture
    10 on at

    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.

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

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

  • mark66221 Profile Picture
    10 on at

    Thank you that gives me some insight

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    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?"

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 83 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans