0

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.

Kavya AS
  • 11
  • 2
  • CURL is a HTTP client. It can upload to a REST API. Are you asking if you can write code, in some language that can do the same as CURL does? Then the answer is yes. – Evert Jul 13 '23 at 07:10
  • I have to use this CURL command every 30 days for multiple files. Is there a way to automate this process? – Kavya AS Jul 13 '23 at 07:16
  • Yes you could put the same command in a script, and use CRON to automatically run the script daily. – Evert Jul 13 '23 at 07:18
  • Is there a way to call the REST API used behind this CURL command? – Kavya AS Jul 13 '23 at 07:22
  • What do you mean with that exactly? The CURL command already calls the REST API. Are you trying to call it with a tool that's not CURL? – Evert Jul 13 '23 at 07:23
  • Right I want to call this REST API using SoapUI or Postman instead of CURL. – Kavya AS Jul 13 '23 at 07:35
  • Ok, where did you get stuck with this? – Evert Jul 14 '23 at 08:33

1 Answers1

0

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.

HomeLander
  • 61
  • 3