I can access Jira (cloud hosted) in my browser, but I can't access it via RESTful API. Why?

Deleted user March 26, 2020

I access my team's Jira instance every day to do my work. However, when I try to interact with this instance via the REST API, I get nowhere.

Consider this sample Python client code:

~~~~~~~~~~~~~~~~~~~~~

import requests
from requests.auth import HTTPBasicAuth
import json
import base64

s = requests.Session()

url = "https://REDACTED-CLOUD-INSTANCE-NAME/rest/api/2/search"

headers = {
"Accept": "application/json",
'Authorization': 'Basic ' + base64.b64encode('doug:REDACTED-API-TOKEN')
}

query = {
'jql': 'project = SPT'
}

response = s.get(
url,
headers=headers,
params=query,
#auth=auth
)

print response.text

~~~~~~~~~~~~~~~~~~~~~

The output is:

"{\"errorMessages\":[\"The value 'SPT' does not exist for the field 'project'.\"],\"warningMessages\":[]}"

If I change the code to comment out the 

params=query

arg in the HTTP GET, then script output becomes:

"{\"startAt\":0,\"maxResults\":50,\"total\":0,\"issues\":[]}"

If I change the url line to

url = "https://REDACTED-CLOUD-INSTANCE-NAME/rest/api/2/issue/createmeta"

then the script's output becomes

"{\"expand\":\"projects\",\"projects\":[]}"

If I change the code above to supply my username and password rather than my username and API token I get:

"Basic auth with password is not allowed on this instance"

 

What's going on here?

Is this some kind of permissions issue?

My API Token is valid.

Do I not have permission to interact with the REST API?

 

Thanks,

 

UPDATE

It appears that when I change this line

'Authorization': 'Basic ' + base64.b64encode('doug:REDACTED-API-TOKEN')

to instead read

'Authorization': 'Basic ' + base64.b64encode('REDACTED-EMAIL-ADDRESS:REDACTED-API-TOKEN')

then the problem symptoms documented above go away.

Hmmm...

So, old-style usernames are still permitted by the JIRA web application, but they are not permitted by the REST API?

If that's true, then where is it documented?

I don't see it mentioned in https://developer.atlassian.com/server/jira/platform/basic-authentication/.

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events