Jira REST API, access denied.

Chris Taylor June 23, 2019

 

I am trying to use the Jira REST api to pull data from a Jira project into another app.  I have been following the documentation here https://developer.atlassian.com/cloud/jira/platform/rest/v3/  and I have created a token for my account at this location https://id.atlassian.com/manage/api-tokens

When I use the following PHP code I get the error message "Issue does not exist or you do not have permission to see it."

$headers = array( 'Accept' => 'application/json', 'Bearer' => 'my-token-here' );
$response = Unirest\Request::get( 'https://christaylordeveloper.atlassian.net/rest/api/3/issue/KM-299', $headers );

The token is for my own account and I can view this issue via the web.  Why can I not view my issue via this REST API call?

 

1 answer

1 accepted

0 votes
Answer accepted
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.
June 24, 2019

Hi @Chris Taylor 

I use C# for the API and don't know PHP, but there seem to be a couple of things missing / incorrect :

  • I use Basic authentication with my token, not Bearer
  • My authentication is made up as a combination of my Jira e-mail address AND the token - you don't seem to be using e-mail address
  • The authentication is then base 64 encoded
  • The header for authentication is titled Authorization

If you look at my reply in this post, there is some sample C# code which does all of the above (N.B. this is an old post, so change password for token

It may be useful to try this initially via Postman to get it working

Chris Taylor June 24, 2019

I have switched to Basic authentication and it works perfectly.  Thanks for the advice.

Suggest an answer

Log in or Sign up to answer