Running this query:
"https://someurl.com/graph/users/%24myuser%40myorg.org/licenseDetails?$select=skuId,skuPartNumber"
Results in:
"The request URI is not valid. Since the segment 'users' refers to a collection, this must be the last segment in the request URI or it must be followed by an function or action that can be bound to it otherwise all intermediate segments must refer to a single resource"
After some playing around, I managed to make it work by adding a second dollarsign (%24) before myuser.
This seems to be poorly documented, even here https://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/abnf/odata-abnf-construction-rules.txt.
Is there a c# library that correctly escapes a given literal string for odata instead of everyone manually hitting problems from time to time ?
Shouldn't the doc be improved for these special cases that don't seem to be documented ?
A $
prefix in an OData url typically designates that your are about to use a System Query Option, such as $filter
, $select
or $expand
. This is likely causing your key to be interpreted as such.
Since you're using an entity key to access a specific entity then navigate to one of it's navigation properties, you can typically provide the key directly within parenthesis on the entity. This is simple when you don't have a composite key, and looks like this:
/users('my-key-value')
You can then expand a particular navigation property and select down to specific properties (assuming the implementation is compliant with this) in the same way you were previously attempting, leading to
/users('$myuser@myorg.org')/licenseDetails?$select=skuId,skuPartNumber