Page 1 of 1

RESTful URI and accessing PDF files, etc

Posted: Mon Jan 04, 2010 9:32 am
by alex.barylski
I am reading up on REST again, according to the Wiki:
The application does, however, need to understand the format of the information (representation) returned, which is typically an HTML, XML or JSON document of some kind, although it may be an image, plain text, or any other content.
So requesting a RESTful resource it can return any document of any type, whether that JSON, XML, or PDF, etc. I guess you just have to remember to set the proper mime-type.

I am curious though, what might the URI look like, as fetching reports is just retreiving, no deleting, editing, etc of the PDF output:

Code: Select all

domain.com/reports/2/other/params
domain.com/users/reports/2/other/params
One of the ideas (as I understand) of REST is to clean up the URI namespace but the abve looks nasty, however its not possible to POST data to a report generator when in reality is want GET to be used anyway. I am not certain parameters would be required as I think everything the report builder would need would be available through the ID of the report being generated.

Cheers,
Alex

Re: RESTful URI and accessing PDF files, etc

Posted: Mon Jan 04, 2010 2:22 pm
by VladSun
How about

Code: Select all

domain.com/reports.pdf/2
domain.com/users.pdf/reports/2

Code: Select all

domain.com/reports.xml/2
domain.com/users.xml/reports/2
?

Re: RESTful URI and accessing PDF files, etc

Posted: Mon Jan 04, 2010 9:07 pm
by alex.barylski
I suppose any would work, for some reason though I am somewhat against 'type' being specified in REST URI's (no argument just a personal thing I guess). At the very least I would probably add the extension in as the last component of a URI just to stick with common convention.

Cheers,
Alex

Re: RESTful URI and accessing PDF files, etc

Posted: Tue Jan 05, 2010 12:04 am
by Christopher
Seems like you a mixing clean URLs and RESTful URLs. If you are just requesting reports then you will not be maintaining state anywhere, so they will be RESTful anyway.

And I don't see why you don't want type in the URL. Isn't that the point of REST? That you ask for a resource specifically by URL and it is returned to you? If the system knows by some reason other than the URL itself what data you want returned ... then it isn't very RESTful.