Given a working curl command (with options) in a bash file:
#!/bin/bash
curl 'https://digi.kansalliskirjasto.fi/rest/binding-search/search/binding?offset=0&count=10000' \
-H 'Accept: application/json, text/plain, */*' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'Pragma: no-cache' \
--data-raw '{ "authors":[],
"collections":[],
"districts":[],
"endDate":null,
"formats":["JOURNAL","PRINTING","NEWSPAPER"],
"fuzzy":false,
"hasIllustrations":false,
"importStartDate":null,
"importTime":"ANY",
"includeUnauthorizedResults":false,
"languages":[],
"orderBy":"RELEVANCE",
"pages":"",
"publicationPlaces":[],
"publications":[],
"publishers":[],
"query":"freedom",
"queryTargetsMetadata":false,
"queryTargetsOcrText":true,
"requireAllKeywords":true,
"searchForBindings":false,
"showLastPage":false,
"startDate":null,
"tags":[]
}' \
--compressed \
--output my_file.json
I would like to pass the following custom arguments:
myQUERY="freedom"
myFORMATS='["JOURNAL","PRINTING","NEWSPAPER"]'
myFUZZY="false"
to my --data-raw option as variables for "query", "formats" and "fuzzy". I tried several alternatives:
"formats":$myFORMATS, "query":$myQUERY, "fuzzy":$myFUZZY,
or
"formats":${myFORMATS}, "query":${myQUERY}, "fuzzy":${myFUZZY}
or
"formats":"${myFORMATS}", "query":"${myQUERY}", "fuzzy":"${myFUZZY}"
neigther of those returned desired resutls of the initial bash code!
What is the easiest way to manipulate the custom variable into a command option?
Cheers,