hi,i trying to get all accounts records by odata endpoint with list all contacts ,in order to do this,used below url in my post man:
https://crm-preview.***/main/api/data/v9.0/accounts/contact_customer_accounts?$select=firstname
and my response
"@odata.context": "https://crm-preview****/main/api/data/v9.0/$metadata#accounts(name,contact_customer_accounts(firstname))", "value": [ { "@odata.etag": "W/\"2922751\"", "name": "Hockey Federation", "accountid": "46ef24d1-a0c1-e911-b42a-005056a8646b", "contact_customer_accounts": [], "contact_customer_accounts@odata.nextLink": "https://crm-preview.***/main/api/data/v9.0/accounts(46ef24d1-a0c1-e911-b42a-005056a8646b)/contact_customer_accounts?$select=firstname" }, { "@odata.etag": "W/\"2181982\"", "name": "Corporate Club", "accountid": "a0e0aef4-04c8-e911-b42a-005056a8646b", "contact_customer_accounts": [], "contact_customer_accounts@odata.nextLink": "https://crm-preview.***/main/api/data/v9.0/accounts(a0e0aef4-04c8-e911-b42a-005056a8646b)/contact_customer_accounts?$select=firstname" },
as you can see , contact_customer_accounts is empty array.
if i put ID in my accounts everything worked but i want to get all my accounts records with details of contacts.
Hello Farbodkain,
I guess this should help.
{
"@odata.context":"[CRM_URL]/api/data/v9.1/$metadata#accounts(accountid,contact_customer_accounts(lastname))",
"value":[
{
"@odata.etag":"W/\"20120024\"",
"accountid":"5e505212-fdeb-e811-a96e-000d3a30d104",
"contact_customer_accounts":[
{
"@odata.etag":"W/\"42719331\"",
"lastname":"Patel",
"_parentcustomerid_value":"5e505212-fdeb-e811-a96e-000d3a30d104",
"contactid":"85589fca-982d-e811-a950-000d3a30d7c8"
},
{
"@odata.etag":"W/\"20302661\"",
"lastname":"sdfds",
"_parentcustomerid_value":"5e505212-fdeb-e811-a96e-000d3a30d104",
"contactid":"2f7c5e10-fdeb-e811-a971-000d3a30d7c8"
}
],
"contact_customer_accounts@odata.nextLink":"[CRM_URL]/api/data/v9.1/accounts(5e505212-fdeb-e811-a96e-000d3a30d104)/contact_customer_accounts?$select=lastname"
},
{
"@odata.etag":"W/\"20120016\"",
"accountid":"de46dea5-f7eb-e811-a971-000d3a30d7c8",
"contact_customer_accounts":[
{
"@odata.etag":"W/\"20302665\"",
"lastname":"Payal",
"_parentcustomerid_value":"de46dea5-f7eb-e811-a971-000d3a30d7c8",
"contactid":"137573ab-f7eb-e811-a977-000d3a30dc28"
}
],
"contact_customer_accounts@odata.nextLink":"[CRM_URL]/api/data/v9.1/accounts(de46dea5-f7eb-e811-a971-000d3a30d7c8)/contact_customer_accounts?$select=lastname"
},
{
"@odata.etag":"W/\"14540944\"",
"accountid":"0de7b55a-aa68-e811-a95c-000d3a30da4f",
"contact_customer_accounts":[
{
"@odata.etag":"W/\"27676910\"",
"lastname":"Neel",
"_parentcustomerid_value":"0de7b55a-aa68-e811-a95c-000d3a30da4f",
"contactid":"9fe89072-a8c0-e811-a969-000d3a30da4f"
}
],
"contact_customer_accounts@odata.nextLink":"[CRM_URL]/api/data/v9.1/accounts(0de7b55a-aa68-e811-a95c-000d3a30da4f)/contact_customer_accounts?$select=lastname"
},
{
"@odata.etag":"W/\"27675357\"",
"accountid":"958bd9e4-f2d1-e811-a969-000d3a30da4f",
"contact_customer_accounts":[
{
"@odata.etag":"W/\"27675358\"",
"lastname":"Contact",
"_parentcustomerid_value":"958bd9e4-f2d1-e811-a969-000d3a30da4f",
"contactid":"6ad2cf39-f3d1-e811-a969-000d3a30da4f"
}
],
"contact_customer_accounts@odata.nextLink":"[CRM_URL]/api/data/v9.1/accounts(958bd9e4-f2d1-e811-a969-000d3a30da4f)/contact_customer_accounts?$select=lastname"
},
{
"@odata.etag":"W/\"21984066\"",
"accountid":"0c2af21a-daeb-e811-a96a-000d3a30da4f",
"contact_customer_accounts":[
{
"@odata.etag":"W/\"21984067\"",
"lastname":"Migration Contact Name",
"_parentcustomerid_value":"0c2af21a-daeb-e811-a96a-000d3a30da4f",
"contactid":"ea4e7526-daeb-e811-a977-000d3a30dc28"
}
],
"contact_customer_accounts@odata.nextLink":"[CRM_URL]/api/data/v9.1/accounts(0c2af21a-daeb-e811-a96a-000d3a30da4f)/contact_customer_accounts?$select=lastname"
}
]
}
Hello Farbodkain ,
I am afraid I do not have a direct way of achieving this . I will leave this thread open for anyone to asisst. If I do find ways to achieve this I will update on it .
Bhartendu Pandey
Support Engineer - Customer Engagement- Dynamics CRM/PowerApps/Power Automate
Microsoft
thanks, but i need all contact related to one account .this query only return primary contact.
Hello Farbodkain,
There is no way to update Odata version number as such. It is expected that the Odata call should reflect the same version number of the CRM server.
I had a trial organization set up with Sample data and I was able to get the results for all accounts with related contacts .
below is the exact URL i used .. https://[orgurl]/api/data/v9.1/accounts?$select=name&$expand=primarycontactid($select=contactid,fullname).
Can you try using the exact same URL and see if you are able to retrieve the results?
Please mark my answer as verified if you found it helpful. Please let me know if you have any other questions around the above.
Bhartendu Pandey
Support Engineer - Customer Engagement- Dynamics CRM/PowerApps/Power Automate
Microsoft
thanks , i checked and only different found out is url which use "api/data/v9.1" version 9.1 and im using version 9.0. i don't know how can upgrade my crm odata to better version. if you have any suggestion to give me a clue ,really appreciated to share with me.
and about second link fetchXML , im working on it. i don't know anything about it.
Hello Farbodkain,
Thank you for writing to us. I see we are trying to get details of all contacts related to all accounts. I tried quickly checking through and the same may be possible as per the use of the below link
Retrieve related entity records by expanding single-valued navigation properties.
Also sometimes we may want to construct the query to retrieve the records in dynamics CRM . This can be done by using the Advanced find and then getting the fetchXML . Once you get the fetch XML you can use the restbuilder to construct Odata queries .
Please feel free to browse through the below links in the community article
https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/305214/odata-query
Please mark my answer as verified if you found it helpful. Please let me know if you have any other questions around the above.
Bhartendu Pandey
Support Engineer - Customer Engagement- Dynamics CRM/PowerApps/Power Automate
Microsoft
Daivat Vartak (v-9d...
225
Super User 2025 Season 1
Eugen Podkorytov
106
Muhammad Shahzad Sh...
106
Most Valuable Professional