bash script REST API request problem

summary="Abnormal End"
data=`cat <<EOF
'"fields": {"project":{"key": $key},"summary": $summary,"description": $description,"issuetype": {"name": $name}}'
#echo $data
curl -D- -u user:psswd -X POST --data {$data} -H "Content-Type: application/json" http://localhost:8081/rest/api/2/issue/

Error :

{"errorMessages":["Unexpected character (''' (code 39)): was expecting double-quote to start field name\n at [Source: org.apache.catalina.connector.CoyoteInputStream@1616d88; line: 1, column: 3]"]}

I'm trying to write a bash script wich can do REST API request from data of a CSV file. Can someone help me to resolve this error ?

(I need key, summary, description and name fields as variables to use these later import from a CSV file.)

2 answers

1 accepted

0 votes
Accepted answer

I found the solution with the command eval :

eval curl "-D- -u user:pswd -X POST --data ${data} -H \"Content-Type: application/json\" http://localhost:8081/rest/api/2/issue/"

Having trouble understand how the script should look written out, do I keep the brackets in the script or are they there just for display reasons? Can you provide how this is supposed to look in an executable?



Suggest an answer

Log in or Sign up to answer
Community showcase
Published yesterday in Feedback & Announcements

How do you analyze GC logs, thread dumps and head dumps?

Hi awesome community!  In this article, I would like to describe the one of the toolset (service) for the analyze some problems on different Java-based instances, of course, as Atlassian admini...

91 views 0 7
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you