I have a bash script where I am storing some hostnames in a bash array which I read in from a file. I would then like to pass that array to the description on the jira I am trying to create using the Jira Server Rest API v2. However, with the following code, I keep getting an error. If someone can provide some guidance it'd be much appreciated.
counter=0
declare -a hosts
while read line
do
hosts[$counter]=$line
done < hostsfile.txt
curl --request POST --url 'https://myjiraurl.com/rest/api/2/issue' --header 'Authorization: Basic <auth_code>' --header 'Accept: application/json' --header 'Content-Type: application/json' --data '{ "fields": { "description": "This is an automated JIRA.\nHost List:'${hosts[@]}'", "issuetype": { "id": "10000" }, "project": { "id": "13806" }, "summary": "Host List" } }'
The error I am getting is
{"errorMessages":["Unexpected end-of-input in VALUE_STRING\n at [Source: org.apache.catalina.connector.CoyoteInputStream@6bc37815; line: 1, column: 239]"]}curl: (7) Failed to connect to host1 port 80: Connection refused
curl: (7) Failed to connect to host2 port 80: Connection refused
curl: (7) Failed to connect to host3 port 80: Connection refused
curl: (3) [globbing] unmatched close brace/bracket in column 106