The following example queries an account record, expanding the primary contact lookup, and on the primary contact expands the created by lookup. Each level has a select statement to demonstrate how it works at the different layers. For reference, I am using Postman to perform my tests.
Request:
GET [Organization URI]/api/data/v9.1/accounts(85268bf8-448a-ea11-a812-000d3a579cc6)?$select=name&$expand=primarycontactid($select=fullname;$expand=createdby($select=fullname)) HTTP/1.1
[EDIT] *Note that you do not need to included the navigation property you wish to expand in they query.
{
"@odata.context": "https://admissions-dev.crm.dynamics.com/api/data/v8.2/$metadata#accounts(primarycontactid,primarycontactid(fullname,createdby(fullname)))/$entity",
"@odata.etag": "W/\"2082428\"",
"accountid": "85268bf8-448a-ea11-a812-000d3a579cc6",
"primarycontactid": {
"@odata.etag": "W/\"2081664\"",
"fullname": "Yvonne McKay (sample)",
"contactid": "32278bf8-448a-ea11-a812-000d3a579cc6",
"createdby": {
"fullname": "Paul Breuler",
"systemuserid": "17541fec-8178-4196-84cc-240a576e308c",
"ownerid": "17541fec-8178-4196-84cc-240a576e308c"
}
}
}GET [Organization URI]/api/data/v9.1/accounts(85268bf8-448a-ea11-a812-000d3a579cc6)?$select=name&$expand=primarycontactid($select=fullname;$expand=parentcustomerid_account($select=name;$expand=primarycontactid($select=fullname;$expand=parentcustomerid_account($select=name;$expand=primarycontactid($select=fullname;$expand=parentcustomerid_account($select=name;$expand=primarycontactid($select=fullname;$expand=parentcustomerid_account($select=name;$expand=primarycontactid($select=fullname;$expand=parentcustomerid_account($select=name;$expand=primarycontactid($select=fullname))))))))))) HTTP/1.1
Response
{
"@odata.context": "https://admissions-dev.crm.dynamics.com/api/data/v8.2/$metadata#accounts(name,primarycontactid(fullname,parentcustomerid_account(name,primarycontactid(fullname,parentcustomerid_account(name,primarycontactid(fullname,parentcustomerid_account(name,primarycontactid(fullname,parentcustomerid_account(name,primarycontactid(fullname,parentcustomerid_account(name,primarycontactid(fullname))))))))))))/$entity",
"@odata.etag": "W/\"2082428\"",
"name": "Fourth Coffee (sample)",
"accountid": "85268bf8-448a-ea11-a812-000d3a579cc6",
"primarycontactid": {
"@odata.etag": "W/\"2081664\"",
"fullname": "Yvonne McKay (sample)",
"contactid": "32278bf8-448a-ea11-a812-000d3a579cc6",
"parentcustomerid_account": {
"name": "Fourth Coffee (sample)",
"accountid": "85268bf8-448a-ea11-a812-000d3a579cc6",
"primarycontactid": {
"fullname": "Yvonne McKay (sample)",
"contactid": "32278bf8-448a-ea11-a812-000d3a579cc6",
"parentcustomerid_account": {
"name": "Fourth Coffee (sample)",
"accountid": "85268bf8-448a-ea11-a812-000d3a579cc6",
"primarycontactid": {
"fullname": "Yvonne McKay (sample)",
"contactid": "32278bf8-448a-ea11-a812-000d3a579cc6",
"parentcustomerid_account": {
"name": "Fourth Coffee (sample)",
"accountid": "85268bf8-448a-ea11-a812-000d3a579cc6",
"primarycontactid": {
"fullname": "Yvonne McKay (sample)",
"contactid": "32278bf8-448a-ea11-a812-000d3a579cc6",
"parentcustomerid_account": {
"name": "Fourth Coffee (sample)",
"accountid": "85268bf8-448a-ea11-a812-000d3a579cc6",
"primarycontactid": {
"fullname": "Yvonne McKay (sample)",
"contactid": "32278bf8-448a-ea11-a812-000d3a579cc6",
"parentcustomerid_account": {
"name": "Fourth Coffee (sample)",
"accountid": "85268bf8-448a-ea11-a812-000d3a579cc6",
"primarycontactid": {
"fullname": "Yvonne McKay (sample)",
"contactid": "32278bf8-448a-ea11-a812-000d3a579cc6"
}
}
}
}
}
}
}
}
}
}
}
}

Like
Report
*This post is locked for comments