Skip to main content
All CollectionsAPI
Build API - How to upload a provisioning profile and/or distribution certificate to App Center and configure a branch for Build via the API
Build API - How to upload a provisioning profile and/or distribution certificate to App Center and configure a branch for Build via the API
Jihye E avatar
Written by Jihye E
Updated over 3 years ago

App Center prides ourselves in being API-first. We empower users to automate their CI/CD pipeline via our APIs, and you can expect API support for everything you see in the portal. We have a swagger as well as documentation on how to get stared with our APIs.

Here are the steps to upload a provisioning profile and/or distribution certificate to App Center and configure a branch for Build:

1. Create a new asset to upload the file.

POST /v0.1/apps/{owner_name}/{app_name}/file_asset  

curl -X POST"https://api.appcenter.ms/v0.1/apps/username/DiceOut-01/file_asset" -H "accept:application/json" -H "X-API-Token: {API-token}" -H"Content-Type: application/json" 

The requirement parameters are owner_name ({username}) and app_name ({DiceOut-01}), and this returns the {id}, {location}, {token}, {uploadDomain}, {uploadWindowLocation} and {urlEncodedToken}. Please pass your {API-token} as a header. Here is the documentation on how to obtain your API token, please see steps 1-8 in the first section.

2. Start the upload process by adding the metadata with file name, file size.

POST {uploadDomain}/upload/set_metadata/{id}?file_name={xxx}&file_size={xxx}&token={urlEncodedToken} 

The parameters {uploadDomain}, {id}, {urlEncodedToken} are returned in step 1. You may run a CLI command to get the parameters {file_name} and {file_size}. 

For example, if you are on Mac or Linux software operating systems, in the bash shell, 

  • To obtain your file name, `cd` into your directory where the file is located, and run `ls` to get your {file_name}

  • To obtain your file size, run ls -l {file_name} to obtain the file size

This will return several properties such as {id}, {chunk_size}, {chunk_list} etc. {chunk_size} is the size of chunks to be uploaded, and {chunk_list} is an array of {chunk-id}.

3. Spilt the data into chunk of bytes based on the property {chunk_size} returned in step 2. 

4. Start the upload by chunks. 

For every chunk, run:

POST {uploadDomain}/upload/upload_chunk/{id}?block_number={chunk-id}&token={urlEncodedToken} 

5. When all the chunks have been uploaded, send the finished call to the upload service.

POST {uploadDomain}/upload/finished/{id}?token={urlEncodedToken}

6. The upload is done. 

7. Configure the branch 

POST /v0.1/apps/{owner_name}/{app_name}/branches/{branch}/config 

In the request body, include the “toolsets”property, which has “xcode” property, which can include either the/both “provisioningProfileUploadId” or/and “certificateUploadId”.

Make sure targetBundleIdentifier in the request body is correct. Check the response from GET /v0.1/apps/{owner_name}/{app_name}/branches/{branch}/toolset_projects for the value.

You can use GET /v0.1/apps/{owner_name}/{app_name}/branches/{branch}/config request to your previously configured branch, and find the properties such as certificateFileId and provisioningProfileFileId in the response object.

In general, it's a good idea to check the API details by inspecting network traces when uploading in the portal.

Congratulations, you are done! 🎉

Did this answer your question?