【发布时间】:2017-01-31 07:50:21
【问题描述】:
我尝试使用 python 连接 HP QC 以创建缺陷并附加文件,但我无法连接 HP QC。这是我的代码:
domain='DEFAULT_773497139'
project='773497139_DEMO'
import requests
url = "https://almalm1250saastrial.saas.hpe.com/qcbin/"
querystring = {"username":"user@gmail.com","password":"password"}
headers = {
'cache-control': "no-cache",
'token': "5d33d0b7-1d04-4989-3349-3005b847ab7f"
}
response = requests.request("POST", url, headers=headers, params=querystring)
#~ print(response.text)
print response.headers
new_header = response.headers
new_url = url+ u'rest/domains/'+domain+u'/projects/'+project
new_querystring = {
"username":"user@gmail.com",
"password":"password",
"domain":'DEFAULT_773497139',
"project":'773497139_DEMO'
}
print new_url
response = requests.request("POST", new_url, headers=new_header, params=new_querystring)
print(response.text)
现在登录工作正常,但是当尝试它要求的其他 API 时,我会收到以下消息:
Authentication failed. Browser based integrations - to login append '?login-form-required=y' to the url you tried to access
如果已添加参数,则返回登录页面。
【问题讨论】:
-
反应是什么?
-
响应 202 但它转到登录页面 @DanielSanchez
-
对于域 api,登录后响应为 405,它要求进行身份验证
-
代码已更新@DanielSanchez
标签: python rest api post hp-quality-center