Weird behavior when using cookies

Samuel Wayne January 17, 2012

Hi,

When I tried to create an issuelink from REST API v4.4, I noticed that when you pass the credentials in your curl example, all works fine and the link is created. But when you use the cookie that's already set, it says "You don't have permission to view the specified issue". Certainly, I did verify that there is no session time-out.

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Jeremy Largman
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 23, 2012

This was a bit tricky. I tried it out and have a guess as to what might be happening to you.

Try this, when logging in:

curl -c cookie.txt -H "Content-Type: application/json" -d '{"username" : "admin", "password" : "admin"}' http://localhost:8080/rest/auth/latest/session

Note in particular the "-c cookie.txt" section. I suspect your login wasn't actually writing out a cookie, but only giving the JSON response.

I've added a note to the documentation.

Samuel Wayne January 23, 2012

Thanks Jeremy. I was logging in using the exact same command as you suggested. But still I get the same Permission issue. I'm not sure where it went wrong.

Jeremy Largman
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 24, 2012

I'm doing my testing on localhost (a downloaded version), and not over https, but I got it working. Here's my exact syntax, for both commands:

curl -c cookie.txt -H "Content-Type: application/json" -d '{"username" : "admin", "password" : "admin"}' http://localhost:8080/rest/auth/latest/session
curl -b cookie.txt -H "Content-Type: application/json" -d '{ "linkType": "Duplicate", "fromIssueKey": "TEST-1", "toIssueKey": "TEST-2" }' http://localhost:8080/rest/api/2.0.alpha1/issueLink

0 votes
MattS
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 19, 2012

Can you post the curl commands?

Samuel Wayne January 19, 2012

curl -b cookie-jar -H "Content-Type: application/json" -d '{ "linkType": "Duplicate", "fromIssueKey": "TEST-1", "toIssueKey": "TEST-2" }' https://company-name.atlassian.net/api/2.0.alpha1/issueLink

TAGS
AUG Leaders

Atlassian Community Events