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
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.
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"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.