Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,460,008
Community Members
 
Community Events
176
Community Groups

Getting 401 error for a valid Bitbucket user account, when trying to access API from Jira cloud

Hi,

I am trying to invoke Bitbucket API from Jira using automation rule. I used a service account created in Bitbucket for authorization, it was working fine but recently we had an Atlassian outage which was there for 7 days. After that, our old app pwds were invalid so created a new app pwd, and converted it to base64 "username:apppwd" and using this string to invoke the API, but I am getting 401 error.

When I tried my personal username, its working fine and not working with service account, the service account status is enabled in Bitbucket. Could you please help.

Thanks

1 answer

1 accepted

0 votes
Answer accepted

Hi @ppushpam,

I would suggest checking the following:

1) Have you generated the app password for the service account or for your personal account?

If you are using the username of the service account, the app password should be generated for the service account.

Please make sure that the app password has enough permissions for the operation you want to perform.


2) After you generate the app password for the service account, can you try running the API call with curl from your terminal, for testing purposes?

An example would be the following:

curl -u username:app-password https://api.bitbucket.org/2.0/repositories/workspace-id

replace username and app-password with the values for username and app password of the service account, and also the API URL with the one you are using.

What is the output of this call in your terminal?

Kind regards,
Theodora

Hi @Theodora Boudale ,

Thankyou for your response!

1. I created the app pwd for the service account, providing it full access and admin access. 

2. I used the curl command and output is authorized, I got "200" response.

Creds issue.PNG

But when I am using it in the Jira automation rule, it says unauthorized. I converted "username:app-password" to Base64 string and using it in the header as :

Authorization: Basic "Converted string" 

Hi @ppushpam,

Thank you for the info. Could you please try one more thing:

Run from terminal

curl -v https://api.bitbucket.org/2.0/repositories/workspace-id/ -H "Authorization: Basic converted_string"

where

https://api.bitbucket.org/2.0/repositories/workspace-id/ Replace with the API URL you use in your Jira Automation rule

converted_string replace with your Base64 string without any extra quotes

and let me know the output you get (200 or 401). This is to double-check whether the issue may be with the converted string.

Kind regards,
Theodora

Hi @Theodora Boudale ,

Please find the output of curl command in the attached image, it doesn't contain whole output, Let me know if you want the full output content.

Bitbucket_output.PNG

Hi @Theodora Boudale ,

Following up on the issue, was this output helpful to interpret the cause?

Hi @Theodora Boudale ,

The issue is fixed now, Thanks a lot for your help.

Hi @ppushpam,

It's good to hear that the issue has been fixed. Was there a problem with the converted string? The output you posted in the attached image shows a 401 response as well, so I would assume that the culprit is with this string.

Kind regards,
Theodora

Hey @Theodora Boudale ,

Looks like there was some confusion with the service account username I was considering, later i used the correct username and it worked ass expected.

Thanks

Thank you for the update on this, I'm glad you figured this out.

Please feel free to reach out if you ever need anything else.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events