I am working on a project using the BLS API.
Reference: http://www.bls.gov/developers/api_unix.htm
My current script follows:
declare id=""
echo -n "Enter id: "
read id
echo -n "enter startyear: "
read startyear
echo -n "enter endyear: "
read endyear
curl -i -X POST -H 'Content-Type: application/json' -d '{"seriesid": ["$id"], "startyear":'$startyear' , "endyear":'$endyear'}' http://api.bls.gov/publicAPI/v2/timeseries/data/
I have edited it and put in the ID by hand like on the reference page and that worked. I cannot seem to read the $id from input and insert it into the curl command. Any assistance with this is greatly appreciated thank you.
edit1:
I updated the code and changed the quotes for the {} for the -d option to double quotes and the same error persists.
edit2:
after updating the file with the code provided in the comments I receive a:
Warning: You can only select one HTTP request!
when I run it.
$idis not being expanded because it is inside single quotes.-Iinstead of-i.-I(make a HEAD request) rather than-i(include response headers). An HTTP request cannot be both a HEAD request and a POST request.