What's a good way to return a partial success response for a REST API?

I am working on a use case where I have a dependency on a downstream API. The problem is, for me, a single resource consists of multiple resources for a subsequent service. So a single entry to my API could be internally multiple calls to an external service, and any of those calls could fail.

If all is well, I return an empty 200 OK response, and in the event of an invalid request or server error, I return a separate error response. What should I return in case of partial success? I know the response code 207 Multi-status, but not sure if it applies here as it looks like it is more applicable to batch operation. Answer 207 with a list of failed substructures looks like the best bet at the moment. Any ideas for a cleaner way would be appreciated.

+3


source to share


1 answer


It was more of a design choice, so finally I went with the following response model 1. Success - 200 OK with applicable body 2. Partial success - 200 OK with applicable body plus warnings 3. Error (4xx / 5xx) - error, in which lists errors



+1


source







All Articles