I have setup a developer account and created a access token as described in the docs using "custom application" and providing key, id and secret in the console.
Requests made via the console such as get_survey_list
work fine.
However if I try any other http client like curl I get this:
{"status":3,"errmsg":"Expected object or value"}
The curl code is:
curl -H 'Authorization:bearer xxx' -H 'Content-Type: application/json' https://api.surveymonkey.net/v2/surveys/get_survey_list/?api_key=xxx --data-binary ''
I have tried other methods (httpclient, poster, in my appliction) I always get this result.
My request looks absolutely identical to the request data that is shown in the console output.
The only request that works is user/get_user_details
.
Can anybody help?
Thanks Gordon
You have to request certain data fields with the --data-binary
flag. For example, if I want:
"title","analysis_url","date_created","date_modified"
my curl statement looks like this:
curl -H 'Authorization:bearer xxx' -H 'Content-Type: application/json' https://api.surveymonkey.net/v2/surveys/get_survey_list/?api_key=xxx --data-binary '{"fields":["title","analysis_url","date_created","date_modified"]}'
(please replace XXX with your authenticate parameters)
Read more details here - the page also includes a full example of the curl statement:
curl -H 'Authorization:bearer XXXYYYZZZ' -H 'Content-Type: application/json' https://api.surveymonkey.net/v2/surveys/get_survey_list/?api_key=your_api_key --data-binary '{"fields":["title","analysis_url","date_created","date_modified"], "start_date":"2013-02-02 00:00:00", "end_date":"2013-04-12 22:43:01", "order_asc":false, "title":"test3"}'
get_survey_details
can be called with no parameters, but it still requires a valid JSON object to be POSTed. As Miles commented, a simple empty JSON object will suffice: {}
The error message you got, "Expected object or value", indicates that no JSON object could be decoded from the POST data.