0

我正在尝试以 JSON 格式获取调查结果,但 API 以 XML 格式给出响应。API 列出了 json 响应也可用,但是在发出请求时我必须使用哪个属性却无处可寻。

https://surveyjs.io/Help/Api/GET-api-Surveys-getSurveyPublicResults-id_from_till?apiType=private&renderType=desktop

https://api.surveyjs.io/private/Surveys/getSurveyPublicResults/{id}?from={from}&till={till}

4

1 回答 1

0

我相信您需要确保您的请求有一个值为“application/json”的“Accept”标头。

例如,如果您使用 jQuery,您可以执行以下操作:

var settings = {
  "url": "https://api.surveyjs.io/private/Surveys/getSurveyPublicResults/{id}?from={from}&till={till}",
  "method": "GET",
  "timeout": 0,
  "headers": {
    "Accept": "application/json; charset=utf-8"
  },
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
于 2020-12-27T17:46:15.120 回答