Reputation: 636
How can multiple fields in an Acumatica REST API call be expanded?
/entity/Default/17.200.001/Customer?$expand=Contacts
works, and
/entity/Default/17.200.001/Customer?$expand=Salespersons
works, but
/entity/Default/17.200.001/Customer?$expand=Contacts,Salespersons
does not, leaving neither of them expanded.
According to Acumatica documentation :
Integration->Working with the Contract-Based REST API->Parameters for Retrieving Records->$expand
they say they follow OData conventions (https://www.odata.org/documentation/odata-version-3-0/url-conventions/)
which I believe this request adheres to.
Upvotes: 2
Views: 3059
Reputation: 8278
I've asked a colleague about this behavior. The hypothesis is that expanding multiple inquiry with OData syntax works but it can't expand more than 1 entity array. I say hypothesis because the web service error returned when trying to expand 2 entity arrays is too generic to pinpoint this as the issue.
Currently released documentation doesn't seem to touch on that limitation but it should be coming soon with updated web service documentation. Note that this only applies when fetching all entity. If you were to select a single entity (ex: select 1 customer by ID) then you could expand more then 1 array. There are less limitation on single entity because there is less of a need to optimize the performance on 1 vs X entities.
You can expand multiple single entity and an array:
$expand=Contacts,MainContact,BillingContact
But can't expand multiple arrays:
$expand=Contacts,Salespersons
In web service endpoint screen left pane tree view, the array entity have array notation [] (highlighted in red in image below) while the single entity doesn't have []:
Upvotes: 3
Reputation: 636
Possible work arounds:
1) If an expanded list of all Customers and all fields is required
a) Write a Generic Inquiry
b) Make multiple calls, expanding only one list each time
2) If the number of Customers is fairly small
a) Use the /Customer/{id}?$expand=... for each customers {id}
The benefit of (2a) is that BQL delegates are supported, since (1b) may get a "View Answers has BQL delegate" error. (1a) probably requires the most work.
Upvotes: 1