apihttphttp-response-codespercent-encodinguriencoding

What is the correct HTTP response for requests without percent encoded URI?


Talking about HTTP API/HTTP Web server, what is the HTTP response code that the server should returns in case the client did not apply a URL encoding to requests params. I tried to look into HTTP RFCs but nothing specific or useful regarding that.


Solution

  • If the request is invalid, you can return a 400 Bad Request status.

    400 Bad Request

    The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.

    (Source)

    If you want to send a more informative or specific response, you can provide additional details in the response body.