TestProject Forum
Powered by leading experts in the test automation community

Python Script to upload ipa/apks via API

Hey guys,

Apologies if this has been answered somewhere else. I had a look and could not find this specifically answered anywhere else.

Currently, the way we are set up is that we build and distribute our builds via App Center.

I am looking for a solution that can basically download the latest builds from App Center and then upload them straight to TestProject.

Now, I am relatively new to Python and API testing so the first thing I started doing was play with the API via Postman and managed to work out how to download the latest App Center build and upload it to TestProject using the endpoints provided, but for some reason the Application listed on TestProject never seems to update so I must be missing something somewhere.

I was wondering if you had an example Python script that you could provide to send me in the right direction on how to do this properly?

I am confident that once I have an initial example to look at, I should be fine sorting out the rest.



Hello @daniel1 and thanks for reaching out.

The final step after performing the file upload should be confirming the file upload to finalize the process.

The steps should be:

  1. Get the upload URL from the API.
  2. Upload the file to the URL.
  3. Confirm the file upload using the API.

See following endpoint:

Hey there David.

Thanks for the info!

So does that mean the POST has to happen in order to finalise everything? I just figured that was to confirm the upload was successful. I get a success message on the PUT so figured that meant the upload was a success.

Also, do you know of any resources I could refer to in regards to an example python script that shows how to upload the files using these endpoints?

An update on this: After using the POST endpoint, I can now successfully upload files so thanks for that!

Just need more info on the Python side of things now, if possible?

Thanks so much again for all your help!

Hello @daniel1
You can use the requests library in Python to send the POST and GET request to do the same thing in python.

Here is a code sample:

import requests

import json



# Get file upload url.

get_upload_link_request = requests.get('https://api.testproject.io/v2/projects/PROJECTT ID/applications/APPLICATION ID/file/upload-link',

                                       headers={'Authorization': API_TOKEN})


    upload_url = json.loads(get_upload_link_request.text)['url']


    # Upload file to url.

    headers = {'content-type': 'application/octet-stream'}

    with open(FILE_PATH, 'rb') as app:

        upload_file_request = requests.put(upload_url, data=app, headers=headers)


    # Confirm Upload

    data = {"fileName" : "test.apk"}

    confirm_upload = requests.post(url='https://api.testproject.io/v2/projects/PROJECT ID/applications/APPLICATION ID/file/', headers={'Authorization': API_TOKEN}, data=data)


except Exception as e:


That works perfectly!

Thanks so much, @ran.tzur & @david.goichman for all of your help!