Hi,
I am using some custom entities in common data services, let's call them "parent" and "child", where there is a one-to-many relationship between them. I'm trying to count how many children each parent has, and as far as I can tell from the documentation here https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/query-data-web-api#aggregate-and-grouping-results I should be doing something like:
GET api/data/v9.0/children?$apply=groupby((parent/parentid), aggregate(parentid with countdistinct as total))
but I get an error:
'child' entity doesn't contain attribute with Name = 'parent' and NameMapping = 'Platform'".
Even if I take off the aggregation clause like this:
GET api/data/v9.0/children?$apply=groupby((parent/parentid))
the error message is the same.
If I replace either the word "parent" or "parentid" with gobbledygook I get a different and sensible error message so I know I'm putting in the correct names
Also if I do this:
GET api/data/v9.0/children?$filter=(parent/parentid eq 'xxxx-xxxxxx-xxxx')
then I get the result I'd expect, so it shows I can follow the child->parent relationship inside the filter but seemingly not inside the apply.
I've searched on the forums for that error message and most of the occurrences seemed to be down to server-side caching but I'm using Dynamics 365 online so there's nothing I can do about that.