0

I have to make request with only one parameter for example:

example.com/confirm/{unique-id-value}

I don't expect to get any data in body, only interested in Response Code.

Need advice which method to use GET or POST

GET i think is also OK because, making request with pathparam, but on the other hand POST is also right to use, because i don't expect to receive any data from body, just making informative request and interested in only status code of request result.

4
  • Check this out: spring.io/understanding/REST Commented Mar 19, 2018 at 14:53
  • Since you are not adding new values to db you should go for @GET Commented Mar 19, 2018 at 14:53
  • What does the server implementation require? Commented Mar 19, 2018 at 14:57
  • i'm making service which will call other services functions and they will create their service according my request, therefore i dot want to look like a bad coder and trying to write clean code Commented Mar 19, 2018 at 15:04

2 Answers 2

1

The confirm suggests that a request to this URL will change some state on a server by 'confirming' some 'task' that is identified by a unique ID. So we talk about the Reource (the R in REST) of a 'task confirmation'. A GET request will get the current state of such a Resource. GET must not have side effects like changing the state of the 'task confirmation' resource. If it is unconfirmed before a GET request, it must be unconfirmed after such a request.

If you want to change the state of the 'task confirmation' Resource, you must use a different HTTP verb. But since you write that you will not pass any request body, it is hard to recommend a RESTful approach.

Sign up to request clarification or add additional context in comments.

Comments

1

One disadvantage of using GET is that its response is often cached, so if you inquire about the same ID repeatedly, you might not get the results you expect, unless you do some shenanigans to prevent caching (such as appending a unique timestamp to the GET URL for every request). POST requests, on the other hand, are never cached, so you would get the correct result every time without any additional work.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.