Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

NEST Web API with C#: Using JSON objects to create and associate Accounts with Contacts

Posted on by 10

We are using a Json object in C# to pass values to POST a new Account to our CRM.  Along with this we are passing the primarycontactid with values for first and last name.

This creates the Account along with a Contact that is associated to the Account as the primarycontact.

I t does not associate the Contact to the Account.

we would like to do this all with one call so are there any suggestions on how we should do this?

we are using httpClient1.PostAsync

Here is the current JSON:

accountnumber: "4"

primarycontactid: " 'firstname': 'John' 'lastname': 'Smith' "

name: "Amarillo College VN"

address1_line1: "6222 W. 9th Ave"

address1_city: "Amarillo"

address1_stateorprovince: "Texas"

address1_country: "USA"

address1_postalcode: "79106"

also where can we find out about any more of these tricks where we could consolidate multiple tasks within 1 request?

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: NEST Web API with C#: Using JSON objects to create and associate Accounts with Contacts

    Hello,

    Check this - docs.microsoft.com/.../create-entity-web-api

    It looks close enough to what you try to perform.

  • Suggested answer
    Nya Profile Picture
    Nya 29,056 on at
    RE: NEST Web API with C#: Using JSON objects to create and associate Accounts with Contacts

    Hi,

    Have you tried to modify the value of primarycontactid with the GUID of the contact instead of the first name and last name?

    The GUID of the contact can be found in the URL of the contact’s main form.

     pastedimage1622800526473v1.png

    If this helped you, I'd appreciate it if you'd mark this as a Verified Answer, which may in turn help others as well.

    Best Regards,

    Nya

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans