Diego Victor de Jesus
Diego Victor de Jesus

Reputation: 3003

Appropriate request method to send tokens

What is the correct method to consume a resource passing a token after i am correctly authenticated? For example, is it right to do a GET with a Bearer Authorization to get an array of JSON objects or should i make a POST request?

Upvotes: 1

Views: 28

Answers (1)

Bishakh Ghosh
Bishakh Ghosh

Reputation: 1258

According to Wikipedia

GET requests a representation of the specified resource. Note that GET should not be used for operations that cause side-effects, such as using it for taking actions in web applications. One reason for this is that GET may be used arbitrarily by robots or crawlers, which should not need to consider the side effects that a request should cause.

and

POST submits data to be processed (e.g., from an HTML form) to the identified resource. The data is included in the body of the request. This may result in the creation of a new resource or the updates of existing resources or both.

So, it does not depend on passing a token. It depends whether your request just retrieves the resource or it creates/updates an existing resource.

For just retrieving a resource use GET.

For creating a new resource/updating a new resource use POST.

Upvotes: 1

Related Questions