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.
I think that you would need parse this jql query to URI.
Instead:
project = ProjectName AND Organizations = "OrgName" and status in ("STATUS1", "STATUS2")
try replace to:
project+%3D+ProjectName+AND+Organizations+%3D+%22OrgName%22+and+status+in+%28%22STATUS1%22%2C+%22STATUS2%22%29
I used the site https://www.url-encode-decode.com/ to it
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.