1

I have read this GREAT answer regarding REST. I have few questions regarding it:

  1. According to the answer and what i read, new resource creation needs happen using the PUT verb but in most cases when you create a resource you need to provide parameters and sometimes binary data. what is the way to do it with PUT? isn't it more natural to do it with multipart POST?
  2. Can someone direct me to an example for use of PUT to send both binaries and String, preferably using the httpClient library.
  3. What verb to use if i want something that is beyond the basic CRUD actions? like generate a report regarding one of the resources.

Thanks

Community
  • 1
  • 1
special0ne
  • 6,063
  • 17
  • 67
  • 107

1 Answers1

2

You are confusing the HTTP Verb with the actual payload. Nothing prevents you from using a multipart payload for PUT. POST can be used to create new resources, but you are usually POSTing to a different URL. As a side-effect, a new resource might get created and returned in the Location header. PUT is used if you already have the URL to a resource.

REST != CRUD.

A restful architecture forces you to think in resources. So 'report' might be a good candidate for a resource.

You could POST your report parameters to a resource like /..../reports (for example) and create a new report resource that way. Put the URL for the report in said Location header and use a GET to actually get the report data (or return the report data right away)

Jochen Bedersdorfer
  • 4,093
  • 24
  • 26
  • Hi, thanks for the swift response. I also thought that put call can be multipart but the lack of examples as well as the fact that Apache FileUpload library does does not recognize multipart in PUT calls made be little confused. – special0ne Jun 30 '11 at 01:05