Can 403 Response has a response body

104 Views Asked by At

My question is it possible to have a response body for response with 403 forbidden status. My understanding is 403 implies that the user has no access to the resource. Will it is be appropriate or correct implementation to return a response body for such requests

2

There are 2 best solutions below

0
Jeremy Fiel On

Yes, it's recommended to use a common Error Message response for any errors encountered in your api surface.

I highly recommend using RFC9457 - Problem Details for HTTP APIs error.

0
VoiceOfUnreason On

The 4xx (Client Error) class of status code indicates that the client seems to have erred. Except when responding to a HEAD request, the server SHOULD send a representation containing an explanation of the error situation, and whether it is a temporary or permanent condition. -- RFC 9110.