I tried to execute a CURL statement as follows, for which I am getting required response:
curl -s -POST --header 'Content-Type: application/json' 'http://www.dummy.com/projectname/page_relevance' -d '{"query": "q_string", "results": [{"abstract": "abs_string", "title": "title_string"}, "mode": "value", "cache": true, "source": "value"}'
But when i tried to pass variable values to parameter "query", the curl statement mentioned below not works and observed some error statement in response:
curl -s -POST --header 'Content-Type: application/json' 'http://www.dummy.com/projectname/page_relevance' -d '{"query": "$query_string", "results": [{"abstract": "abs_string", "title": "title_string"}, "mode": "value", "cache": true, "source": "value"}'
ERROR Statement:
Not Found [CFN #0005]
It works!
This is the default web page for this server.
The web server software is running but no content has been added, yet.
But am sure that curl request which i constructed second with variable resembles the same curl request which i executed at first. This is tested using echo which replaces $query_string with correct value.
I also tried in another approach, in which i have not used any variables for single parameter, instead i tried as below:
a='{"query": "query_value", "results": [{"abstract": "abs_string", "title": "title_string"}, "mode": "value", "cache": true, "source": "value"}'
curl -s -POST --header 'Content-Type: application/json' 'http://www.dummy.com/projectname/page_relevance' -d $a
I also tried to substitute value of a using ${a}
, "$a"
, '$a'
still same error is been observed.
See Question&Answers more detail:
os