janhommes / o.js

o.js - client side oData lib.
https://janhommes.github.io/o.js/example/
MIT License
238 stars 57 forks source link

On batch changeset, include the content ids, status codes, and response bodies in the result #124

Closed bprucha closed 3 years ago

bprucha commented 3 years ago

On batch changeset, include the content ids, status codes, and response bodies in the result. These are important pieces of information for processing batch changeset responses. It also standardizes the response format rather than having different data types, one for just status code when no body is provided and another with the response body but no status code.

Also fix bug on batch error where response JSON body not included in the exception. In the try block {res, error} is being thrown which is immediately being caught in the catch block which throws only res so the error JSON body gets lost.

janhommes commented 3 years ago

@bprucha thanks for contributing. I am willing to accept this, but can you merge my latest changes to fix the tests? Also, we might need a test for this (to make it more clear) as of now, I don't understand it fully (lately not working that much with odata and batch request at all.

bprucha commented 3 years ago

@janhommes I'd be happy to make a test case but not sure of a public .NET WebAPI OData service that I can use for the tests. The services.odata.org implementation is based off of Restier which behaves differently. In the Microsoft implementation, when an individual operation in a batch change set fails, the response status is 200 with the body being a batch response including the content id of which operation failed. That allows you to determine of all the operations that were sent, which of them triggered the actual error. The Restier implementation sends an error response status with the body being a generic OData error. It's not a batch response body so it leaves you guessing as to which one of the batch operations actually triggered the error.

bprucha commented 3 years ago

To be clear I'm referring to the Microsoft implementation of the .NET WebAPI OData service:

janhommes commented 3 years ago

@bprucha yeah this is an issue we are having for quite a while (see issue #64). The unit test might spin up an own server for verifying. But that is quite a huge task. Let's keep the test so long simple and track it in the ticket.

Will trigger a release soon. Thanks for contributing. If you like you can update the package.json and add your name there.