Uploading APK gives Unauthorized error

I’m trying to automatically upload an APK to the Experitest Server, as described in “Upload your Application to Your Project using cURL”, using the following shell script:

curl								\
    --location							\
    --request POST 'http://…:8080/api/v1/applications/new'	\
    --header 'Cache-Control: no-cache'				\
    --header 'Content-Type: multipart/form-data'		\
    --header 'Authorization: Basic …'				\
    --form 'file=@….apk'					\
    --form 'project=Default'

And I’m getting the following error message:

{
  "timestamp":"2020-01-31T12:30:28.764Z",
  "status":401,
  "error":"Unauthorized",
  "message":"Bad credentials",
  "path":"/api/v1/applications/new"
}

I’m pretty sure I got the correct proper authentication string as both Postman and the Obtaining Access Key function give me the same string.

Are there any caveats to know when it comes to uploading APK files?

Where are you running this Rest request against?
Are you against Appium Studio agent or Seetest cloud ?

Neither. We have a private cloud.

I have retried again Postman and at one point Postman changed to a shorter access string. The original access strings where about 200 character and the new one is less the 20 character.

And with that shorter key it actually works. Why this is I don’t know.

The next hurdle is the missing update function — having to work with only a new and update will be mayor pain.

As far are I know its

curl -v -i -X POST -k -H "Authorization: Bearer " -F file=@C://eribank.apk https://…:8080/api/v1/applications/new

Your command shows ‘Authorization: Basic’ instead of Authorization: Bearer

The video you made clearly shows to use basic authentication:

See:

https://docs.experitest.com/display/TE/Native+Applications+Testing

Is the documentation outdated?

Please try ‘Access Key’ (Using https://docs.experitest.com/display/TE/Obtaining+Access+Key) in Authorization header with “Bearer”.

I will check on the documentation.

In the end I used my user-id and password to the upload with postman. After uploading one file with postman I used the code feature to check the used code:

It’s important the check after sending the file beause only then the Authorization filed is filled in.

Great that it worked and thanks for sharing.

Let me understand, after using postman you again ran a cURL command for to query the uploaded file?

1 Like

Even better I got both “Basic Auth” and “Bearer Auth” to work! :grin:

1 Like