0

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 ?

kumol
  • 174
  • 1
  • 9

1 Answers1

2

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.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • Do you think 204 is suitable for not updating any document though there was no error and also the document was found ? – kumol Sep 14 '21 at 08:37
  • If the document was found, there was no error and no changes were made, the appropriate response would be either 200 or 304 – datenwolf Sep 14 '21 at 19:16