We are using system views to filter which entity records to return from the Web API. The filtering works great, but it messes up the way the data is returned when used in conjunction with $expand.
Searching contacts with an $expand AND a savedQuery:
/contacts?$select=firstname,createdon&$expand=parentcustomerid_account($select=name;$expand=primarycontactid($select=fullname))&savedQuery=5da27be3-1da1-ea11-a812-000d3a1b88d8
{
"@odata.etag": "W/\"4984909\"",
"contactid": "49a0e5b9-88df-e311-b8e5-6c3be5a8b200",
"createdon": "2017-01-20T22:39:39Z",
"fullname": "a tester",
"firstname": "a",
"_LinkEntityAliasPrefixparentcustomerid_account_x002e_name": "Adventure Works"
}
parentcustomerid_account.name does come back in a predictable (albeit unusual) format, but the nested $expand of primarycontactid doesn't come back at all.
If I drop the savedQuery parameter, the $expand data comes back as expected:
/contacts?$select=firstname,createdon&$expand=parentcustomerid_account($select=name;$expand=primarycontactid($select=fullname))
{
"@odata.etag": "W/\"4984909\"",
"contactid": "49a0e5b9-88df-e311-b8e5-6c3be5a8b200",
"createdon": "2017-01-20T22:39:39Z",
"fullname": "a tester",
"firstname": "a",
"parentcustomerid_account": {
"name": "A Datum Corporation",
"accountid": "a16b3f4b-1be7-e611-8101-e0071b6af231",
"primarycontactid": {
"fullname": "Yvonne McKay (sample)",
"contactid": "7f264114-298e-ea11-a811-000d3a569af5"
}
}
}
Is this a bug?
Is there a way to use a savedQuery in conjunction with $expand (and nested $expand) and get the data returned in the proper format?
Thanks,
Chris
Hello,
I don't think it's doable. My recommendation - use ?fetchXml querying to get the data you need - docs.microsoft.com/.../retrieve-and-execute-predefined-queries
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156