1

We have existed API like

/api/activiation_code each time, the activiation_code will be different, then server will create a token for this call and return it, usually each call will have different activiation_code which return different token.

Since this API need server to create something so it is designed as POST.

Can we design this API as HTTP GET ?

What is the pro and cons ?

Forrest
  • 122,703
  • 20
  • 73
  • 107

1 Answers1

0

You could design the API to support GET requests, but I would not recommend this. If your API is accessible via a website, a user could accidentally activate an account multiple times since the URL will be stored in the browser's history. Additionally, web crawlers could potentially supply values to your API through the URL if you support GET requests.

POST requests are much better because the information is included in the body of the request, not the URL. Thus, it is much less likely that something will go wrong accidentally.

Jack Humphries
  • 13,056
  • 14
  • 84
  • 125