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

How to create an entity with self-reference? #2010

Open
HeikoTheissen opened this issue Oct 10, 2024 · 2 comments
Open

How to create an entity with self-reference? #2010

HeikoTheissen opened this issue Oct 10, 2024 · 2 comments
Labels
JSON Format JSON Format Protocol Protocol, URL Conventions V4.03 Too vague or controversial for 4.02

Comments

@HeikoTheissen
Copy link
Contributor

HeikoTheissen commented Oct 10, 2024

How to create an entity with server-generated entity ID that contains at the same time a self-reference? Can this be done with a JSON batch request?

{"requests": [{
  "id": "1",
  "method": "post",
  "url": "Employees",
  "body": {...}
}, {
  "id": "2",
  "dependsOn": ["1"],
  "method": "put",
  "url": "$1/Manager",
  "body": {
    "@context": "$metadata#$ref",
    "@id": "$1"
  }
}]}

Can the $1 reference appear in the body in this position? The JSON batch specification contains only examples with $1 in url or headers.

@HeikoTheissen HeikoTheissen added Protocol Protocol, URL Conventions JSON Format JSON Format labels Oct 11, 2024
@ralfhandl
Copy link
Contributor

Not possible yet, would need some templating mechanism for constructing request bodies.

Any template media types out there that we can reuse?

@HeikoTheissen
Copy link
Contributor Author

Introducing a new variant of the OData bind operation may be simpler than introducing a templating mechanism (although the latter could be useful elsewhere). The proposed @bindurl accepts the same values as the request URL, so you can write:

{
  "id": "2",
  "dependsOn": ["1"],
  "method": "patch",
  "url": "$1",
  "body": {
    "Manager@bindurl": "$1"
  }
}

This would not only allow self-references, but also batch requests that create two entities with a reference between them.

@ralfhandl ralfhandl added the V4.03 Too vague or controversial for 4.02 label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JSON Format JSON Format Protocol Protocol, URL Conventions V4.03 Too vague or controversial for 4.02
Projects
Status: No status
Development

No branches or pull requests

2 participants