Home > Net >  What would be the status code if a put request has no error but not updating any thing?
What would be the status code if a put request has no error but not updating any thing?

Time:09-16

I created an put api and it takes updated object, But what I need to update is already available in the document. Though it doesn't create any change it returns with status code 200. What may be the suitable status code for this case ?

CodePudding user response:

Look at it from the other way round: What's the status code, for if a PUT request made an actual alteration (say update or created a record in a database, e.g.)? It's 201 – Created.

So 200 is actually the right status code here. But in your situation I'd test, that actual alterations result in a 2xx different from the (idempotent) 200 - Ok.

  • Related