RESTful URI and accessing PDF files, etc

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

RESTful URI and accessing PDF files, etc

Post 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
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: RESTful URI and accessing PDF files, etc

Post 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
?
There are 10 types of people in this world, those who understand binary and those who don't
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: RESTful URI and accessing PDF files, etc

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: RESTful URI and accessing PDF files, etc

Post 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.
(#10850)
Post Reply