It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Struggling to use the API for cloud Jira

We have a cloud Jira setup, authenticated via Google. I followed the docs and created a token. When I do a curl -v https://<my_company>.atlassian.net --user me@my_company:mytoken, I get a 302 redirect to /secure/MyJiraHome.jspa. There are no headers returned with a session ID or similar.

If I try to view an issue, I get a 404 error: Issue does not exist or you do not have permission to see it. 

curl -v --user me@my_company.com:token  https://my_company.atlassian.net/rest/api/2/issue/RM-399

And yet the issue is clearly visible on the web at https://my_company.atlassian.net/browse/RM-399.

What am I missing?

4 answers

So the answer was - don't make a typo! I misspelled my company's domain name; once I fixed it everything was good.

 

As Homer Simpson would say: Doh!

 

Thanks all for the help.

Hi Ken,

Technically, your curl command is correct and should return you the correct issue's data.  

The 404 hints at an authentication problem, i.e. Jira doesn't know who you are and will simply pretend the issue isn't there. So, I am guessing that there is an issue with your token.

Also, curling  'https://<my_company>.atlassian.net' isn't much of test of your authentication, as it will always redirect you to '/secure/MyJiraHome.jspa' with 302, no matter if your credentials are good or not.

So, I suggest you check your API token or simply revoke the one you have and create a new one.

Hope that helps,

 Oliver

Thanks, Oliver, but it doesn't look like it's an authentication problem. Nothing changed when I got a new token.

 

One interesting thing: I tried listing my projects with 

/rest/api/3/project/search?jql=&maxResults=50&startAt=0

 

Got a response indicating there are 0 projects:

{"self":"https://<my_company>.atlassian.net/rest/api/3/project/search?jql=&maxResults=50&startAt=0","maxResults":50,"startAt":0,"total":0,"isLast":true,"values":[]}

 

It's acting as if the API doesn't give me the same level of access to my company's projects as the web UI.

Hi Ken,

That's indeed quite strange. Have you tried accessing the API without any credentials – that should yield the same results as the ones you are describing. 

If you are sure the credentials are correct, I really don't know what else to try. The API allowing for different levels of access for the same user would be news to me – although that would be an interesting feature. Anyway, it might be time for a support ticket.

0 votes
Warren Community Leader Sep 16, 2019

Hi @Ken Freeman 

I would recommend trying the same API call in Postman (either the online version or via the downloaded app). This will confirm whether you have an authentication issue or not.

Go with a simple API call like https://my_company.atlassian.net/rest/api/2/issue/RM-399 to get it working

Thanks all. I've opened a support ticket with Atlassian; will let you know what they say.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

The add-in you’ve been waiting for: Jira Cloud for Excel 🙌

Introducing Jira Cloud for Excel Here at the product integrations team at Atlassian, we are thrilled to announce the new Jira Cloud for Excel add-in! This add-in lets you export Jira data directly ...

840 views 5 22
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you