Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

See issue between jiras

Hi community. I

 

've this code to connect My JIRA with other Jira to see issue fields: And it return 401 unauthorized when I'm SITE-ADMIN. What is the problem? Thank's

 

def issueKey = 'TUR-1'

def result = get('https://myJIRA1.atlassian.net/rest/api/2/issue/' + issueKey)
.header ("Authorization", "Basic XXXXXXXXXXX-TOKEN-BY-MY-XXXXXXXXX")
.header('Content-Type', 'application/json')
.asObject(Map)
if (result.status == 200){
return result.body.fields
} else {
return "Failed to find issue: Status: ${result.status} ${result.body}"
}

1 answer

1 accepted

0 votes
Answer accepted
Andy Heinzer Atlassian Team May 11, 2021

Hi Eduard,

I think I see the problem here.  It looks like you are trying to just pass in the API token directly in the authorization header.  This might have worked in the past with Jira Cloud, but today there is an expectation that you will use that API token along with your email address to then create a string of

user@example.com:APItoken

And then base64 encode that string.  The result encoded string is what is expected to be in that authorization header. There is also more info over in Basic Auth for REST APIs.

If you use an incorrect authorization string, it would explain why you cannot see the details of that issue as Jira tends to restrict access based upon your user permissions to view issues.

Try that and let me know if that helps.

Andy

Hi @Andy Heinzer 

 

I try put my user and my token and it not woks, I send a photo if you can help me. Thank's

Captura100.png

Andy Heinzer Atlassian Team May 12, 2021

Yes.  You cannot just pass the email:token. Instead you need to base64 encode that string first and pass that instead.  For example if your email address was fred@example.com and your token was freds_api_token you would have a string of

fred@example.com:freds_api_token

On a linux/unix/mac you can use a command of

echo -n fred@example.com:freds_api_token | base64

The output of which would be

ZnJlZEBleGFtcGxlLmNvbTpmcmVkc19hcGlfdG9rZW4=

You need to pass that string in the authorization header so that in this case it would look something like:

.header ("Authorization", "Basic ZnJlZEBleGFtcGxlLmNvbTpmcmVkc19hcGlfdG9rZW4=")

If you are using a Windows machine, you can also find instructions on how to encode this string over in Basic Auth for REST APIs.  Try that and let me know the results.

Andy

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you