Kavya AS
Kavya AS

Reputation: 21

Derive REST API from CURL command

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.

Upvotes: 0

Views: 128

Answers (1)

HomeLander
HomeLander

Reputation: 103

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.

Upvotes: 0

Related Questions