curl请求JIRA以匿名用户身份登录,即使是有效凭据也是如此

时间:2015-06-15 18:51:02

标签: python html json rest jira

所以我解决了原来的问题(见下文)。但是,我目前的问题是我以匿名用户身份登录(即使该网站有效且以前使用过现场凭据)。

curl -D- -X GET -H "Authorizatio: Basic (rand letters)lashdglsglhasdglasdg==" -H        
"Content-Type: application/json" https://jira.company-
some.net/rest/api/latest/search?jql=project=QA (this project does exist, I verified)

问题是,现在它正在回答这个问题......

HTTP/1.1 400 Bad Request
Date: Mon, 15 Jun 2015 20:39:44 GMT
X-AREQUESTID: 978x78980x1
Set-Cookie: atlassian.xsrf.token=S2XZ-384H-UGNQ-    
RCZ3|6f58fa3340fe45a4360ae177afe49b0e69facda2|lout; Path=/; Secure
X-AUSERNAME: anonymous
Cache-Control: no-cache, no-store, no-transform
X-Content-Type-Options: nosniff
Content-Type: application/json;charset=UTF-8
Connection: close
Transfer-Encoding: chunked

{"errorMessages":["The value 'QA' does not exist for the field 
'project'."],"errors":{}}

帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

如果您要使用“基本身份验证”,请确保username:password的组合是base 64加密的。以下是Groovy中的一个示例:

    Base64.encodeBase64String(("${username}:${password}").getBytes())

JIRA REST API以JSON格式返回响应。