Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$expand Contains Incorrect Context Link #883

Open
alexleen opened this issue Dec 30, 2016 · 1 comment
Open

$expand Contains Incorrect Context Link #883

alexleen opened this issue Dec 30, 2016 · 1 comment
Assignees

Comments

@alexleen
Copy link

alexleen commented Dec 30, 2016

Observed in System.Web.OData 5.9.1 & 6.0.0

I have exposed the the following endpoint:

/entity1('key')/entity2('key')/entity3('key')/entity4('key')

When I execute /entity1('key')/entity2('key')/entity3?$expand=entity4 I receive a JSON response with the correct "@odata.context":

"@odata.context": "https://host:port/$metadata#entity1('key')/entity2('ket')/entity3",
 "value": [
{
  ...,
  "entity4@odata.context": "https://host:port/$metadata#entity1('key')/entity2('key')/entity3('key')/entity4",
  "entity4": [
    {
      ...
    }
  ]
},
...

When I execute /entity1('key')/entity2('key')/entity3('key')?$expand=entity4 however, I receive an incorrect "@odata.context" with two keys:

"@odata.context": "https://host:port/$metadata#entity1('key')/entity2('ket')/entity3",
 "value": [
{
  ...,
  "entity4@odata.context": "https://host:port/$metadata#entity1('key')/entity2('key')/entity3('key')('key')/entity4",
  "entity4": [
    {
      ...
    }
  ]
}

This causes an exception when executing with Microsoft's OData Client:

"The context URL 'https://host:port/$metadata#entity1('key')/entity2('key')/entity3('key')('key')/entity4' is invalid."

@alexleen
Copy link
Author

I've found a workaround:

Using a $filter instead of a key: /entity1('key')/entity2('key')/entity3?$filter=Key eq 'key'&$expand=entity4 provides the correct response:

"@odata.context": "https://host:port/$metadata#entity1('key')/entity2('ket')/entity3",
"value": [
{
  ...,
  "entity4@odata.context": "https://host:port/$metadata#entity1('key')/entity2('key')/entity3('key')/entity4"    ,
   "entity4": [
    {
      ...
    }
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants