Take the 2-minute tour ×

I know HTTP PUT is an idempotent request that store something at a specific URI, according to the definition (quoted from the rfc)


But what is the definition of 'enclosed entity'? It doesn't seem possible for me to send form data (like for HTTP POST request) over. What about sending representation of the entity via JSON/XML or in other serialization formats?

In short, how does one send a HTTP PUT request over to store/update info at a specific URI then?

share|improve this question
en.wikipedia.org/wiki/… –  W55tKQbuRu28Q4xv Dec 18 '10 at 9:23
add comment

4 Answers

up vote 5 down vote accepted

The enclosed entity is the payload data contained in the HTTP message body (after any transfer encodings have been removed.) If you're having trouble sending the message body then it could be that you've forgotten to include a Content-Length header - that's one of two ways to indicate that the HTTP message has a body.

PUT is the same as POST except for this semantic difference: With POST the URI identifies a resource that will handle the entity, such as a servlet. With PUT the URI identifies the entity itself, for example a file that will be created/replaced with the contents of the entity body.

share|improve this answer
add comment

In REST you have:

GET - retrieve resource
POST - create new resource
PUT - update existing resource
DELETE - delete resource

So the PUT verb is used to update an existing resource on the server. Depending on the client there are various ways of sending a PUT request. For example with jquery AJAX:

    type: 'PUT',
    url: '/products/123',
    data: { name: 'new product name' }
share|improve this answer
but how do you issue a HTTP PUT request? is the one posted in the following question the right way? stackoverflow.com/questions/2719610/… –  Jeffrey04 Dec 18 '10 at 9:24
@Jeffrey04, it depends on what the server expects. In the example you are showing it is XML. But you could use other formats as well. I would recommend you watching this video on using REST for SOA. –  Darin Dimitrov Dec 18 '10 at 9:26
jcalcote.wordpress.com/2008/10/16/… good explaination of the different uses of POST and PUT. ITs usage dependant, not action. –  Pheagey Jun 27 at 15:34
add comment

You send a HTTP PUT where the body is the 'enclosed entity' that you wish to store under the requested URL. Very similar to POST, it is only the semantics as specified in the RFC, that differ.

share|improve this answer
do you mind to include an example? thanks –  Jeffrey04 Dec 18 '10 at 9:30
Perhaps you're confused about this: you're actually sending an HTTP POST request — your web browser doesn't support PUT. You pass type=PUT in the form data so your web app (i.e. Rails) knows what to do. –  Paul Schreiber Dec 18 '10 at 16:11
@Paul I'm actually developing a restful api site via php (zend_framework), but I didn't know how PUT is actually done (hence the question) and doesn't look like form input should/can be used. My webserver and the php script are capable of processing PUT requests tho. –  Jeffrey04 Dec 18 '10 at 18:39
add comment

not sure if this is the right answer, but I will probably just try

suppose after issuing a HTTP GET to http://example.org/api/foo/1, I get this

GET http://example.org/api/foo/1
Accept: application/json


    "foo": "bar"

then to issue a put request

PUT http://example.org/api/foo/1
    "foo": "baz"
share|improve this answer
add comment

Your Answer


