Wednesday, February 2, 2022

[SOLVED] Test file upload using HTTP PUT method

Issue

I've written a service using HTTP PUT method for uploading a file.

Web Browsers don't support PUT so I need a method for testing. It works great as a POST hitting it from a browser.

update: This is what worked. I tried Poster but it suffers from the same thing as using fiddler. You have to know how to build the request. curl takes care of the problem.

curl -X PUT "localhost:8080/urlstuffhere" -F "file=@filename" -b "JSESSIONID=cookievalue"

Solution

In my opinion the best tool for such testing is curl. Its --upload-file option uploads a file by PUT, which is exactly what you want (and it can do much more, like modifying HTTP headers, in case you need it):

curl http://myservice --upload-file file.txt


Answered By - alienhard
Answer Checked By - Katrina (WPSolving Volunteer)