What "status code" to use when there is no data in the body of a POST request?

Asked

Viewed 56 times

0

I am creating an application for the client to upload a file to the server and I would like to know what the Status Code ideal to return if in the request the file or any other important data is not sent in the body.

See this example below:

{dado1: "3457", dado2: "0110xFC"} // Status Code: 200  (todos os dados são enviados)

{dado1: "3457"} // Status Code: ??? (faltou enviar o segundo dado)
  • {dado:[{dado1:"3457", dado2:'0110xFC'}]} Is it treating the Object +- this way? I’m just using logic, I’m not really the "programmer" when it comes to Javascript.

1 answer

2


If you made a request that is not valid, the answer is from group 4xx.

It could be a 400 "Bad request", or "Invalid request".

More details of the 4xx errors can be seen here: https://restfulapi.net/http-status-codes/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.