Hi,
I am trying to use transitions API to get and post transitions using postman with Base 64 encoded username and API token and it works fine every time. When I try to automate the flow in gitlab CI with python it worked for some time but now it throws
Hi Marc,
Sure, the token is active as I am using the same token with Postman and it works.
The calls are as follows:
Postman:
GET
https://<company_jira_server>/rest/api/2/issue/<issue_id>/transitions
Headers:
Authorization: Basic <base64(user:token)>
Python:
transitions_url = f"{jira_base_url}/issue/{issue_key}/transitions"
headers = {
"Authorization": f"Basic {jira_auth}"
}
transitions_response = requests.get(transitions_url, headers=headers)
if transitions_response.status_code == 200:
transitions = transitions_response.json()
else:
print(f"Failed to fetch transitions: {transitions_response.status_code}")
print(transitions_response.text)
where jira_base_url = f"{jira_server}/rest/api/2/" and jira_server is the company jira server, the issue_key is the Jira issue id and
jira_auth = base64.b64encode(f"{jira_user}:{jira_token}".encode()).decode()
Hello @Deep Amin
Welcome to the Community!
The error you're facing can be tricky to debug, especially since it worked for some time and then started failing. There should be some change related to your code or the environment but what I'd first ensure that the issue ID or key you are trying to access is correct and exists. Trying with another issue key may give us a clue.
I'd also verify that the user associated with the API token still has the necessary permissions to view the issue. If you haven't done yet.
There might be network-related issues (DNS, proxy settings, etc.) in your CI environment that aren't present in your local environment. It would also be helpful to isolate the request in a simple Python script outside of GitLab CI to verify it’s not a CI-specific issue. If it works in isolation but fails in CI, the issue might be with the CI environment itself.
Sorry, if I wasn't helpful but these are the clues that came to my mind.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have tried with multiple issues as the automation pertains to more than one project and it happens for all of them. I can verify the token permissions with Postman the same rest call works fine. I will try to isolate the script as per your recommendation, however if that was to be the case it would never have worked in CI environment, which is not the case. Thank you in any case for the pointer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Deep Amin
The errors are related to permissions.
Is your token still active or has it expired?
Can you also show the call you are making via postman and python, this will help members on the community.
They might see issues in the call.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.