OData / OData/WebApi

$expand Contains Incorrect Context Link

Open
#883 1 comment 0 reactions 1 assignee View on GitHub

@mikepizzo is already working on this.

Since Aug 3, 2017.

in-progress P2
Dominant language
C#
Stars
864
Forks
467
PR merge metrics
No merged PRs in 30d

Description

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."

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.