Jira REST API Username

Ed Wesley Wells August 22, 2019

I'm calling the Jira REST API using Basic Authentication. However, various online articles indicate the "username" is not my login email address. It appears my actual "username" is not presented anywhere in the Jira UI or Atlassian Account management UI. 

How is one supposed to query the REST API without knowing their username? Can this be provided by Jira Support?

To reproduce:

Using a simple PowerShell script on Windows 10 to enter my email and password. I also tried using just the account part of the email (the part before "@") and my full display  name (various formats). The credential object is used with a simple PowerShell cmdlet named "Invoke-RestMethod". This looks very similar to the cUrl examples in the official documentation for the REST API.

$cred = get-credential

invoke-restmethod -Uri 'https://gitools.atlassian.net/rest/api/latest/issue/SCNG-12' -Method Get -Credential $cred -ContentType "application/json"

 

I can confirm the URI string returns JSON results when I am logged into the Jira website with my account and paste it into an empty browser window. This appears to be some case where I do not have a correct username.

Error:

invoke-restmethod : The remote server returned an error: (404) Not Found.
At line:1 char:1
+ invoke-restmethod -Uri 'https://gitools.atlassian.net/rest/api/latest ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

 

For Reference:

https://developer.atlassian.com/server/jira/platform/rest-apis/

https://confluence.atlassian.com/cloud/blog/2018/06/say-goodbye-to-usernames-in-atlassian-cloud

2 answers

1 accepted

0 votes
Answer accepted
Jimmy Van (GLiNTECH)
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.
August 22, 2019

Hi Ed,

To query the REST API for Jira Cloud, you should be using a REST API token. 

Follow the instructions here to generate a token - https://confluence.atlassian.com/cloud/api-tokens-938839638.html

As you're on Cloud, the second last link you posted should be https://developer.atlassian.com/cloud/jira/platform/rest/v3/ as some of the endpoints are different.

Hope that helps,
- Jimmy

0 votes
Sithija Kumarasiri August 17, 2022

hello

Suggest an answer

Log in or Sign up to answer