Bash Curl and Jira RESTAPI not working

bhushan walde February 5, 2021

Hello,

I am new to Jira and it is not my core competency. I am just trying to create BASH script, This script will read a text file with jira issues, complete the non jira task and update the jira issue.

I am using the curl to update the jira. like below

curl -D- -k -u $WINDOWS_USERNAME:'$WINDOWS_PASSWORD' -X PUT --data '{\"name\":\"$WINDOWS_USERNAME\"}' -H \"Content-Type:application/json\" https://jira.XXXXXXcom/rest/api/2/issue/$TASKNO/assignee"

 

This works from command prompt. But when run through the script. I get some time password issues and CAPTCHA issues and need Jira admin help to clear the account.

 

is there a better way like OAUTH or cookies and how to use then in bash script?

help is appreciated?

 

1 answer

0 votes
Kurt Klinner
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.
February 5, 2021

@bhushan walde 

 

Hi Bhushan

welcome to the Atlassian community.

You should have a look to personal access tokens which are available starting with Jira 8.14 

https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html

Cheers

 

Kurt

bhushan walde February 7, 2021

thank You Kurt fort helping....

 

Hope I will get it right.

 

Cheers

Bhushan

bhushan walde February 7, 2021

Kurt,

I hope you will be able to help me here.

After looking into this, I just realized that our Jira version is 8.13.

So which method I should be using to connect to JIRA using CURL in Version 8.13?

 

Cheers

Bhushan

Kurt Klinner
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.
February 9, 2021

@bhushan walde 

 

Hi Bhushan

 

https://developer.atlassian.com/server/jira/platform/security-overview/ lists the potential options pre 8.14 which are basic auth, cookie based and oauth.

 

Oauth would be the preferred one but i am not sure how this would be done in a bash script. 

 

If a language like python would be an option, than you could take a look at https://shreya-goyal.medium.com/authenticating-jira-rest-api-in-python-and-creating-issues-oauth-4780c58fd478

 

Cheers

Kurt

bhushan walde February 10, 2021

Thank your Kurt,

look like I got what I wanted, The problem with bash is that escape characters need to be added at every double quotes. I will update the thread once I am confident that I resolved all issues and script is working correctly.

 

regards

Bhushan

Suggest an answer

Log in or Sign up to answer