curl requests to JIRA log in as anonymous user even w/ valid credentials

1.5k Views Asked by At

So I fixed my original problem (see below). However my current issue is that I am logged in as an anonymous user (even though giving the site valid and previously used on-site credentials).

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)

The problem is that now it is returning this as an answer...

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":{}}

Help would be appreciated.

1

There are 1 best solutions below

6
On

If you are going to use "basic authentication", make sure that the combination of username:password is base 64 encrypted. Below is an example in Groovy:

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

JIRA REST API returns response in JSON format.