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

bash script REST API request problem

Shengda Liu June 23, 2014
#!/bin/bash
key="ProjA"
summary="Abnormal End"
description="azertyuioqds"
name="Bug"
data=`cat <<EOF
'"fields": {"project":{"key": $key},"summary": $summary,"description": $description,"issuetype": {"name": $name}}'
EOF`
#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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Shengda Liu June 23, 2014

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/"

0 votes
Gregory Hicks October 8, 2015

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?

 

Thanks

TAGS
AUG Leaders

Atlassian Community Events