lundi 29 octobre 2018

Best practise when making post request in JAX-RS

I have seen some different conventions regarding the response status code, when making a post request using JAX-RS.

I have seen this:

  Response.ok(//content or object).build();

My initial thought would be that this is wrong, since status code 200, just means ok, which is a broad term, but since we have 'Posted', I think 201 would be better since it also returns the URI of the element inside the header

 Response.created(//content or object).build();




Aucun commentaire:

Enregistrer un commentaire