Questions tagged [http-method]

HTTP methods used to designate the appropriate action to direct a server towards a resource. GET and POST are the most widely known; PATCH and DELETE also fit in that category, among others.

332 questions
819
votes
11 answers

Use of PUT vs PATCH methods in REST API real life scenarios

First of all, some definitions: PUT is defined in Section 9.6 RFC 2616: The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD…
Dmitry Kudryavtsev
  • 12,114
  • 4
  • 22
  • 30
406
votes
7 answers

What is the difference between POST and GET?

I've only recently been getting involved with PHP/AJAX/jQuery and it seems to me that an important part of these technologies is that of POST and GET. First, what is the difference between POST and GET? Through experimenting, I know that GET appends…
Hristo
  • 42,002
  • 60
  • 155
  • 224
304
votes
6 answers

Should I use PATCH or PUT in my REST API?

I want to design my rest endpoint with the appropriate method for the following scenario. There is a group. Each group has a status. The group can be activated or inactivated by the admin. Should I design my end point as PUT…
java_geek
  • 15,768
  • 29
  • 82
  • 105
260
votes
14 answers

When should I use GET or POST method? What's the difference between them?

What's the difference when using GET or POST method? Which one is more secure? What are (dis)advantages of each of them? (similar question)
Adriana
  • 7,914
  • 13
  • 34
  • 37
216
votes
9 answers

Which HTTP methods match up to which CRUD methods?

In RESTful style programming, we should use HTTP methods as our building blocks. I'm a little confused though which methods match up to the classic CRUD methods. GET/Read and DELETE/Delete are obvious enough. However, what is the difference between…
Drew
  • 14,229
  • 15
  • 63
  • 77
134
votes
3 answers

curl -GET and -X GET

Curl offers a series of different http method calls that are prefixed with a X, but also offers the same methods without. I've tried both and I can't seem to figure out the difference. Can someone explain to me quickly how these two operations…
matsko
  • 20,727
  • 21
  • 94
  • 138
104
votes
4 answers

RESTful Alternatives to DELETE Request Body

While the HTTP 1.1 spec seems to allow message bodies on DELETE requests, it seems to indicate that servers should ignore it since there are no defined semantics for it. 4.3 Message Body A server SHOULD read and forward a message-body on any…
shelley
  • 6,576
  • 2
  • 31
  • 54
102
votes
6 answers

What method should I use for a login (authentication) request?

I would like to know which http method I should use when doing a login request, and why? Since this request creates an object (a user session) on the server, I think it should be POST, what do you think? But since the login request should be…
greg0ire
  • 21,120
  • 15
  • 68
  • 95
68
votes
3 answers

Payloads of HTTP Request Methods

The Wikipedia entry on HTTP lists the following HTTP request methods: HEAD: Asks for the response identical to the one that would correspond to a GET request, but without the response body. GET: Requests a representation of the specified…
Alix Axel
  • 141,486
  • 84
  • 375
  • 483
48
votes
3 answers

What is difference between HTTP methods GET, POST, PUT and DELETE

I am developing REST WCF service and As theoretically i know when to opt for what purpose. GET to get the resource PUT to update POST to Insert DELETE to delete But what is the disadvantage if we don't follow this above rule, suppose to insert a…
Fooker
  • 706
  • 1
  • 8
  • 19
46
votes
8 answers

Rails Responds with 404 on CORS Preflight Options Request

I'm creating a set of services using Rails 4, which I am consuming with a JavaScript browser application. Cross-origin GETS are working fine, but my POSTs are failing the preflight OPTIONS check with a 404 error. At least, I think that's what's…
38
votes
1 answer

What is the HTTP method PURGE?

Today when using Postman I noticed the method option of PURGE. I have never encountered it in practice and cannot find the explanation of it's purpose. What is this method used for, where did it come from, and is there a spec for it somewhere?
Sam Berry
  • 6,195
  • 5
  • 35
  • 52
35
votes
3 answers

How to detect HTTP method in CodeIgniter

How can I detect HTTP method in CodeIgniter controller class? Edited: Is there any other way than using $_SERVER['REQUEST_METHOD'] in CodeIgniter?
Sgn.
  • 1,656
  • 2
  • 14
  • 27
27
votes
1 answer

Any method to get constant for HTTP GET, POST, PUT, DELETE?

For example, HttpServletResponse has the HTTP status codes as constants like public static final int SC_OK = 200; public static final int SC_CREATED = 201; public static final int SC_BAD_REQUEST = 400; public static final int SC_UNAUTHORIZED =…
daydreamer
  • 73,989
  • 165
  • 410
  • 667
21
votes
2 answers

Explain and example about 'get', 'delete', 'post', 'put', 'options', 'patch', 'head' method?

I'm writing a webservice. Could any one explain these above methods and give me some example about them? Thank for your help.
Qui Nguyen
  • 491
  • 1
  • 3
  • 11
1
2 3
22 23