I'm trying to search for the issues that we get out of a JQL query using CURL. I'm substituting the field name with a variable I fetch in the previous steps.
Variable is a migrated custom field eg."Field Name (migrated)"
curl --request POST --url 'https://<baseURL>.atlassian.net/rest/api/3/search' \
--header "Content-Type: application/json" \
--header 'Accept: application/json' \
--header "Authorization: Basic ${token}" \
--data "{\"jql\": \"\"${VAR}\" IS NOT EMPTY\"}"
Error :
{"errorMessages":["There was an error parsing JSON. Check that your request body is valid."]}
When I try this with single quoted for the data it works, but I need to use double quotes so that the Variable can be expanded, does anyone know if the API request needs any updating
Syntax that solved the issue for me:
Explanation for the above syntax:
My input variable was a string like this : "Custom Field (migrated)", since this string contains whitespaces and a round bracket when I did not use the addition double quotes around it, bash assumed those needed to be considered as individual arguments and thus ended up making 3 different sub-vars (not the right term but for the ease of explanation adding it)
Reference : https://stackoverflow.com/a/10067297
Thanks to @Wagner Santos for hinting at using single quotes for all the parts that remain consistent.
I have replaced --data with --json, and it worked for me. Could you please try it out?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Wagner Santos ,
Thank you for the response, unfortunately this too did not work.
Below is the syntax :
I think it is the round brackets in the custom field name that is causing the issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Glad to hear you have found a solution already!
Regarding the --json unknown error, it seems to be related to your curl client version. --json parameter was introduced on version 7.82.0. So you might want to update it.
I also realized this parameter is just a shortcut to make your curl code cleaner when working with JSON. 😆 https://github.com/curl/curl/pull/8314
curl --version can be used to check your client version.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.