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

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

Doug_Axtell I'm New Here Thursday

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
Community showcase
Posted in Jira Software

Metrics Fun: 2019 in Review

Hello, Atlassian Community!  I thought it would be fun to do something different for my teams' last retrospective of 2019 so I'm planning to do a "year in review" with info-graphics.  Wha...

1,886 views 10 14
Join discussion

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