Struggling to use the API for cloud Jira

Ken Freeman September 13, 2019

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

1 vote
Ken Freeman September 17, 2019

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.

1 vote
Oliver Siebenmarck _Polymetis Apps_
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 14, 2019

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

Ken Freeman September 15, 2019

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.

Oliver Siebenmarck _Polymetis Apps_
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 15, 2019

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
Ken Freeman September 16, 2019

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

0 votes
Warren
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 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

Suggest an answer

Log in or Sign up to answer