Add IRIs for created objects in response for POST and PUT request.
See original GitHub issueI’m submitting a
- bug report.
- feature request.
Current Behaviour:
After discussion on slack group we realised that some more details can be added in the response that is returned after a new object is created or updated using PUT/POST request. Currently, the response is in this format:
{
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
"@type": "Status",
"description": "Object with ID f3744cd9-1921-49f6-9caa-c6676678b029 successfully added",
"statusCode": 201,
"title": "Object successfully added."
}
We can add full IRIs for the created object as well, which will make it easier to reference the link or perform operations on the newly created/updated object.
Expected Behaviour:
IRI for the object can be added in the response body.
{
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
"@type": "Status",
"description": "Object with ID f3744cd9-1921-49f6-9caa-c6676678b029 successfully added",
"iri": "http://localhost:8080/serverapi/Movie/f3744cd9-1921-49f6-9caa-c6676678b029",
"statusCode": 201,
"title": "Object successfully added."
}
Steps to reproduce:
Make a PUT/POST request to any Class or Collection endpoint.
Snapshot:
Environment:
- python version
- pip version
- OS details
Do you want to work on this issue?
Yes
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Basics of Creating a REST Service Manually
This appendix describes how to manually create an InterSystems IRIS® REST service by subclassing the %CSP.RESTOpens in a new tab class; this procedure ......
Read more >Creating REST API with InterSystems IRIS, ObjectScript and ...
Creating REST API with InterSystems IRIS, ObjectScript from scratch using GitHub template, VSCode, and Docker container.
Read more >Context Methods - Iris
Note that if the request-response lifecycle terminated ... AddHandler can add handler(s) ... field's query parameters and the POST or PUT form data....
Read more >Creating a OData API Adapter for InterSystems IRIS
Let's create a generic OData client that will abstract the HttpRequest class and make it easier to implement various OData query options. We'll ......
Read more >Request and response behavior for custom origins
For DELETE , GET , HEAD , PATCH , POST , and PUT requests, ... To control how long your objects stay in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
this is something @sameshl and @chrizandr can answer as it is a hydrus design choice
[EDIT] btw returning the full created object or objects would be unjustified in terms of cost (bandwidth), the client already knows which data it submitted. Again PUT response should not have a body according to RFC 7231 section 4.3.4
[EDIT] Plus, the objective of Hydra is mainly to be a “semantic layer” on top of API data, so it makes sense that what is returned is more a “semantic annotation” of the data stored than actual data.
Makes sense. Thanks, @Mec-iS
Was there any specific reason that we chose to return the status in the response rather than the created object itself? While I was going through the cookbook I noticed the expected response from the API contained the newly created object itself- https://github.com/HydraCG/cookbook/blob/master/movies/create-movie.md We are anyways sending the status code in headers as well. Can we think of returning the created object instead of verbose status in the response?