Hi All,
Trying to use the following script to download attachment by using specific jql query. The query works using jira on the cloud, but not through the script.
It only works if i minimize the query to only the project name and leave out the rest.
HOST="XXX"
USER="XXX"
API_TOKEN="XXX"
curl -sL --request POST \
--user "${USER}:${API_TOKEN}" \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--url "https://${HOST}/rest/api/2/search" \
--data '{
"jql": "project = ProjectName AND Organizations = "OrgName" and status in ("STATUS1", "STATUS2") "
"startAt": 0,
"maxResults": 30,
"fields": ["attachment"],
"fieldsByKeys": false
}' \
| jq .issues[]?.fields?.attachment[]?.content \
| xargs -I{} sh -c 'curl -L --user $1 --url $2 --output $(date +%s)_$(basename $2)' - "${USER}:${API_TOKEN}" {}
Would also like some input on:
1. how I could output the attachment name based on ticket nr. Currently I'm doing date+basename, but could not figure out which field to use for ticket.
2. Download only specific attachments for example *.zip files only.