0

I used some web services and made my own. All of them were simple and they were only using simple GET requests like this:

http://foobar.com/api/movies?category=drama&apikey=bsbsbsbsbs

and a JSON data was output according to the parameters provided.

What I wanna do is a fileupload service. Normally if it wasn't a web service I would use HTTP POST for this. How can i do this with REST API? What's the difference between POST and GET requests with respect to REST web services.

Edit: I'm using PHP, please don't give ASP.net examples.

Insignificant Person
  • 863
  • 2
  • 10
  • 24
  • Sorry - missed the PHP part! Answer now removed. – Sean Kearon Nov 04 '14 at 09:55
  • There is nothing special about this, you upload files by POST and PUT, possibly by PATCH too. The only problems is on client side, since it is not easy to upload files via ajax, afaik. you can solve this only with canvas and base64 encoding... – inf3rno Nov 04 '14 at 12:58

1 Answers1

1

In REST you have the CRUD Methods ( Create, Read, Update, Delete) if you want to upload a file you need a PUT(Update) or POST(Create) method. The GET (Read) is only to get data from your Service not for Create, Update, Delete.

Here you will get some more information

http://www.ibm.com/developerworks/library/ws-restwsdl/

REST PHP Example:

http://coreymaynard.com/blog/creating-a-restful-api-with-php/

LynconBaez
  • 26
  • 6
paco
  • 48
  • 9