REST-API With Bash

Incle YC September 3, 2018

Good morning
I am using JIRA in my company.

I've been using JIRA to find out that there is an API and I'm testing it.

I tested using bash to automatically generate JIRA, and I was successful

 

#!/bin/bash

jira_user="id"
jira_pw="pass"
jira_server="jira.test.com"
project="SECURITY"
issuetype="Inquiry"

 

api_data="{\"fields\":{\"project\":{\"key\":\"${project}\"},\"summary\":\"jira test\",\"description\": \"my description\",\"issuetype\":{\"name\":\"${issuetype}\"}}}"

 

 

curl -u "${jira_user}":"${jira_pw}" -w "<%{http_code}>" -H "Content-Type: application/json" https://${jira_server}/rest/api/2/issue/ -X POST --data "${api_data}"


The reason I leave an article is
Assignee can not be specified.

 

 

2 answers

0 votes
Incle YC September 4, 2018

api_data="{\"fields\":{\"project\":{\"key\":\"${project}\"},\"summary\":\"test\",\"description\": \"my description\",\"issuetype\":{\"name\":\"${issuetype}\"}}}"
api_data2="{\"fields\":{\"assignee\":{\"name\":\"${assignee}\"}

 

->

[incle@incle jira]$ ./jira2.sh
./jira2.sh: line 17: unexpected EOF while looking for matching `"'
./jira2.sh: line 18: syntax error: unexpected end of file

0 votes
Alexey Matveev
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.
September 3, 2018

Hello,

Do you mean, that you have some kind of error ,when you specify an assignee? What is the error?

Incle YC September 4, 2018

api_data="{\"fields\":{\"project\":{\"key\":\"${project}\"},\"summary\":\"my summary\",\"description\": \"my description\",\"issuetype\":{\"name\":\"${issuetype}\"}}}"

Is there an option here to change the assginee?

Incle YC September 4, 2018

Is this the right way?

Alexey Matveev
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.
September 4, 2018

You missed a couple of parenthises

api_data2="{\"fields\":{\"assignee\":{\"name\":\"${assignee}\"}}}

Suggest an answer

Log in or Sign up to answer