web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Create and associate with an existing record many-to-many relationship entity data through the web api?

(0) ShareShare
ReportReport
Posted on by

I can't for the life of me figure out or find any documentation for how to create an record and associate it with another record in a many-to-many relationship through the web api.

Similar as the example in https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/create-entity-web-api#bkmk_CreateRelated under "Associate entity records on create" but with a many-to-many.

Let's say I have a entity called Class with a N:N to Student. If I wanted to create a new class with association to a couple of already existing students I assume I would do something like this:

POST: xxx.crm11.dynamics.com/.../classes

{

"students" : [{

"student@odata.bind" : "/students(00000000-0000-0000-0000-0000000001)",

"student@odata.bind" : "/students(00000000-0000-0000-0000-0000000002)"

}]

}

Would this be correct? Or am I misunderstanding something?

I have the same question (0)
  • Suggested answer
    Rui Carvalho Profile Picture
    Microsoft Employee on at

    Hello Stenu,

    I know that you are trying to associate a Class to students when creating the class.
    But when doing this association, and looking into the documentation, it refers to a collection or to a field that comes from the relationship.
    Now on a N:N relationship you don't have a field, I'm assuming you have a grid on the form by going to the related correct?

    Before I jump into the Associate when create the record I would start with Associate only:
    https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/associate-disassociate-entities-using-web-api#add-a-reference-to-a-collection-valued-navigation-property

    The example is for 1:N but you can see that it also refers it should work on N:N
    'This is a 1:N relationship but you can perform the same operation for an N:N relationship.'

    Verify if by associating a Class that already exists with students that already exists works, and then adjust to Create and Associate.

  • Matthieu.Delattre Profile Picture
    25 on at

    Hello,

    In order to find the API to relate and unrelate records in Dynamics, you could use Power Automate and the appropriate CDS nodes and then investigate the code behind the node:

    - Relate records

    - Unrelate records

    pastedimage1594726139893v2.png

    Matthieu DELATTRE

    CRM Consultant

  • Community Member Profile Picture
    on at

    Hey,

    Good idea. I managed to associate a class and students that already exists following the link you sent, but I still struggle with Create and Associate. When I run this it actually works and I get the 204, but it does not associate with the existing student but creates a new, empty student (with a different ID than I sent, obviously)

    POST to uri/api/data/v9.1/cr82e_consolidationresults?

    {

       "new_class" : "ClassName",

       "new_class_new_student" :

           [

               {

                   "@odata.id" : "/new_student(xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx)"

               }

           ]

    }

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 196 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 129

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans