I am passing two date values to a script and trying to use those in a CURL POST command as below:
starttime=$1
endtime=$2
for apps in $(cat testapps.txt)
do
curl -X POST -H "Content-type: application/vnd.appd.cntrl+json;v=1" -d '{"name": "This is a test","timeRange": {"startTimeMillis":"$1","endTimeMillis":"$2"}, "affects": {"type": "APP"}}'
It is giving me 500 internal server error.
If I replace the $1 and $2 value with the date/time as below, it works fine.
curl -X POST -H "Content-type: application/vnd.appd.cntrl+json;v=1" -d '{"name": "This is a test","timeRange": {"startTimeMillis":"2019-05-28T15:00:00-0400","endTimeMillis":"2019-05-28T16:00:00-0400"}, "affects": {"type": "APP"}}'
Am I missing anything?
$1 and $2inside single quotes. see after-dyou are using single quotes. In bash you cannot expand the variable when its inside single quote. Try using double quotes.