'HttpStatus 207 response body suggestions

I was wondering how the response body should look like when the HttpStatus is 207 Multi-status. I failed to find any examples online.

I was thinking something like a list that contains the failed status and the reason for it for each sub-request.

[
    {
        "status" : 404,
        "reason" : "Resource not found"
    },
    {
        "status" : 500,
        "reason" : "Something went wrong internally"
    }
]

Is this the right aproach ? Should I include something else ?

Thanks !



Solution 1:[1]

Follow the specs: the Hypertext Transfer Protocol (HTTP) Status Code Registry will tell you that the reference for 207 Multi-Status is RFC 4918, which internally links to a section on Multi-Status Response

The default Multi-Status response body is a text/xml or application/xml HTTP entity with a 'multistatus' root element. Further elements contain 200, 300, 400, and 500 series status codes generated during the method invocation. 100 series status codes SHOULD NOT be recorded in a 'response' XML element.

To get a better sense for how it is used in practice, you should probably look into one of the open source WebDAV projects (ex: Apache mod_dav).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 VoiceOfUnreason