Sunday, March 16, 2014

https curl POST, GET, DELETE Images or Video files

Hi guys,

So I was trying to test some api's from my terminal and I decided to use CURL for doing POST, GET and DELETE.

Now, the api's use HTTPS so I had to figure out how to do https curl. After Googling for few minutes, I was able to figure it out.

There were few things which were missing from most of the posts. Hopefully this will help someone or save someone's time.

Few points to note

#1 - Url is in double quotes
#2 - query string is encoded.

# upload image/video using POST
curl -i --trace -H --data-binary "@/some/path/to/video/or/image/file" "https://somebaseurl/action?encodedQueryString" -v

#get file using GET
curl -i --trace -H -G "https://somebaseurl/action?encodedQueryString"


# delete file
curl -i --trace -H -X DELETE "https://somebaseurl/action?encodedQueryString"

Thanks


No comments:

Post a Comment