Mauritz Hansen
Mauritz Hansen

Reputation: 4774

RESTful processing function/resource: GET or POST?

I am creating a RESTful web service and some of the resources are computing or processing functions. For instance, it is possible for a user to scale and convert images through the API by submitting an image and receiving the scaled or converted image back.

According to the RESTful Web Services Cookbook, section 2.5, I should use GET:

Treat the processing function as a resource, and use HTTP GET to fetch a
representation containing the output of the processing function. Use query
parameters to supply inputs to the processing function.

This is clear for cases where the inputs are simple (such as the long/lat coordinates of a point). However, should I follow the same advice for larger inputs such as images? As far as I know it is not possible to send this much data as a query parameter.

Upvotes: 5

Views: 1690

Answers (4)

Jim
Jim

Reputation: 73936

The image is a resource. Use PUT to put the resource on the server, then GET the resource, supplying parameters indicating your desired size.

Upvotes: 1

Sid
Sid

Reputation: 7631

Use POST. In effect you are doing an Image Upload and processing on the server. Can't think of another way to do it unless the image is already stored on the server.

Upvotes: 6

Orin
Orin

Reputation: 371

Check out this link http://support.microsoft.com/default.aspx?scid=KB;en-us;q208427. It says that the maximum URL for IE is 2083 characters

Upvotes: 0

MahdeTo
MahdeTo

Reputation: 11184

Due to protocol limitations on HTTP I advice against it. This is a very valid very viable example of an exception that should be made to this rule.

Upvotes: 0

Related Questions