我正在编写一些脚本来从JIRA问题下载附件.作为证明的概念,我通过JIRA API去使用卷曲(在Windows计算机上通过Cygwin的64位),并能够与以下cURL命令来验证和检索问题的充分的代表性(JSON格式):
curl -u username:password -k -X GET https://jira.localhost.com/jira/rest/api/2/issue/{issuekey}
Run Code Online (Sandbox Code Playgroud)
但是,一旦我开始使用python编写脚本(使用请求模块),相同的请求将不再通过
import requests
from requests.auth import HTTPBasicAuth
r = requests.get("https://jira.wgt.com/jira/rest/api/2/issue/{issueKey}", auth = HTTPBasicAuth(username, password), verify = False)
print response.status_code
print response.text
Run Code Online (Sandbox Code Playgroud)
打印:
404
{"errorMessages":["Issue Does Not Exist"],"errors":{}}
Run Code Online (Sandbox Code Playgroud)
使用Charles我也能看到服务器返回301错误(可能是从https重定向到http?).也许请求无法正确处理重定向?关于如何处理这个的任何输入都会很棒