Derive REST API from CURL command

85 views Asked by At

I have the following CURL command to upload file into browser stack custom media. I want to make this process automated. Can I use REST API to do the same?

Like -u is basic authentication in REST API, -F is to update a HTTP form request from a file. Should I pass file name as query param?

---> curl -u "USERNAME:PASSWORD" -X POST "https://api-cloud.browserstack.com/automate/upload-media" -F "file=@\file\TEST.xlsx"

I tried to pass file name as query param and also as json body, I am only getting 401 unauthorized error. But GET and DELETE APIs work with same username and password.

1

There are 1 answers

0
HomeLander On

Please do make sure your user credentials are correct BrowserStack one and first try running the same CURL command on terminal and the try it using REST in code.

Also, you can try online tools which convert CURL command to REST code.