简体   繁体   中英

HTTP Basic auth issue

Doc: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issues/#api-rest-api-2-issue-issueidorkey-get-example

API: https://your-domain.atlassian.net/rest/api/2/issue/{issueIdOrKey}/comment

python script:

url = "https://your-domain.atlassian.net/rest/api/2/issue/{issueIdOrKey}"

auth = HTTPBasicAuth("email@example.com", "<api_token>")

headers = {
   "Accept": "application/json"
}

response = requests.request(
   "GET",
   url,
   headers=headers,
   auth=auth
)

print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

Error

在此处输入图像描述

Update1

  File "test.py", line 1, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

Update2

Install requests then get another issue, please check the pic. And I try to install json via python -m pip install json but cannot do this. 在此处输入图像描述

you are missing an import statement.

at the top of the script try adding:

import requests
from requests.auth import HTTPBasicAuth
import json

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM