question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add IRIs for created objects in response for POST and PUT request.

See original GitHub issue

I’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:closed
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
Mec-iScommented, May 12, 2021

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.

2reactions
priyanshunayancommented, May 12, 2021

As already mentioned, @id in a response status payload is the URI to the actual status response schema.

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found