Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

JIRA API throws 404 most of the times

Deep Amin September 3, 2024

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 

"404
{"errorMessages":["Issue does not exist or you do not have permission to see it."],"errors":{}}" most of the time. I am using the same username/token base64 combination, I have tried using the requests library in python to make the requests and also python Jira library and the issue is persistent. 
What should be the way to further debug it? Is there any known solution?

Thank you!

3 answers

0 votes
Deep Amin September 3, 2024

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()
0 votes
Tuncay Senturk _Snapbytes_
Community Champion
September 3, 2024

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.

Deep Amin September 3, 2024

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.

0 votes
Marc - Devoteam
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 3, 2024

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.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events