Find Questions…

Close ×
First time here? Check out the FAQ!

Weird behavior when using cookies

Samuel Wayne asked this question · 36 karma ·

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.

449 views

2 Answers:

Jeremy Largman [Atlassian] · 10,257 karma ·

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 · 36 karma ·

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] · 10,257 karma ·

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

·1 user liked this

Matt Doar (ServiceRocket) · 5,592 karma ·

Can you post the curl commands?

Samuel Wayne · 36 karma ·

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

Looking for something else?

Find Questions…

or Browse other questions tagged:

or Ask a Question