We're using OData v4.0 and we're trying to get a nested call where we have a $filter and a $select and then an $expand. The $expand also has a $select. The $select and $expand work if they are not added in the same query.
For example; The $select by itself like this.
/adsTradeLineEventReserves?$filter=destTradeDocumentNo eq 'S*1249'&$select=carrierNo,destTradeDocumentNo
Results in
{
"@odata.context": "https://*************/TEST/api/ADS/ADS/v1.0/$metadata#adsTradeLineEventReserves",
"value": [
{
"@odata.etag": "W/\"JzE4OzU4NzkyNTAwODEyMzAyNDA1NzE7MDA7Jw==\"",
"carrierNo": "",
"destTradeDocumentNo": "S00001249"
}
]
}
The $expand by itself like this.
/adsTradeLineEventReserves?$filter=destTradeDocumentNo eq 'S*1249'&$expand=adsReserveItemInventories
Results in
{
"@odata.context": "https://*************/TEST/api/ADS/ADS/v1.0/$metadata#adsTradeLineEventReserves",
"value": [
{
"@odata.etag": "W/\"JzE4OzU4NzkyNTAwODEyMzAyNDA1NzE7MDA7Jw==\"",
"systemId": "df3fda84-b069-ed11-8a35-0022487ef089",
"binCode": "C06",
"ceLabelCode": "NOCU",
"ceUnitOfMeasure": "KG",
"carrierNo": "",
"createdDateTime": "0001-01-01T00:00:00Z",
"createdUserID": "",
"destTradeDocDetLineNo": 0,
"destTradeDocumentLineNo": 10000,
"destTradeDocumentNo": "S00001249",
"destTradeDocumentType": "Document",
"adsReserveItemInventories": [
{
"@odata.etag": "W/\"JzE5Ozc0MjUwNTk4NzIyNTI3MjQ0ODUxOzAwOyc=\"",
"id": "4274ce1e-4d50-ed11-8a2e-0022487ef089",
"EntryNo": 6904,
"ItemNo": "CAPYEL",
"VariantCode": "",
"LotNo": "10000746",
"CarrierNo": "C00002085"
},
{
"@odata.etag": "W/\"JzE5Ozk0OTcyMjQxNjc5MjEzODkxMzkxOzAwOyc=\"",
"id": "5474ce1e-4d50-ed11-8a2e-0022487ef089",
"EntryNo": 6905,
"ItemNo": "CAPYEL",
"VariantCode": "",
"LotNo": "10000746",
"CarrierNo": "C00002086"
}
]
}
]
}
But when I combine the $select and $expand it looks like this.
/adsTradeLineEventReserves?$filter=destTradeDocumentNo eq 'S*1249'&$select=carrierNo,destTradeDocumentNo&$expand=adsReserveItemInventories
This results in an invalid JSON structure as you can see.
{"@odata.context":"https://*************/TEST/api/ADS/ADS/v1.0/$metadata#adsTradeLineEventReserves","value":[{"@odata.etag":"W/\"JzE4OzU4NzkyNTAwODEyMzAyNDA1NzE7MDA7Jw==\"","carrierNo":"","destTradeDocumentNo":"S00001249"
The $expand is completely ignored and the invalid JSON is returned right after the $select. I've tried changing the order and put the $expand up front and the $select at the end. But it results in the same invalid JSON. I also tried removing the filter and adding a server-sided pagination but those two both result in the same invalid JSON.
I'm totally clueless what is going wrong. I expected the OData to return an error instead of an unfinished JSON.