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.

2
  • Sorry - missed the PHP part! Answer now removed. Commented Nov 4, 2014 at 9: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... Commented Nov 4, 2014 at 12:58

1 Answer 1

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/

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.