How to pass a bearer token when making a Jira Align REST API call via Python

Summary

This article demonstrates how to authenticate on the Jira Align Rest API endpoint using the Bearer Token to send calls from a Python Script.

Solution

  • A test with CURL/PostMan or Swagger can validate that the Token being used is valid, if the token does not work in any of these tests it will not work within the Python script as well.

  • An HTTP 401 Error, can indicate an Authentication issue (invalid token being used) or an Authorization issue (The user does not have access to the target object)

The Bearer Token is generated under Profile > API Token. For more details, see also

The method 'POST' to create an EPIC is the example used here, but it does apply to any method and object supported by Jira Align.

This solution is just for internal reference only. Jira Align Support team does not support third-party scripts, but it can be useful during troubleshooting or testing.

import requests url = "https://xxxx.jiraalign.com/rest/align/api/2/Epics" payload = " {"title":"testing epic creation via pythonscript", "state":1, "type":1,"description":"testing epic creation","primaryProgramId":xxx} " headers = { 'Accept': 'application/json;odata.metadata=minimal;odata.streaming=true', 'Content-Type': 'application/json;odata.metadata=none;odata.streaming=true', 'Authorization': 'Bearer user:XXXXXXXXXXXX', } response = requests.request("POST", url, headers=headers, data=payload) print(response.text)

Updated on September 25, 2025

Still need help?

The Atlassian Community is here for you.