如前所述,在 API 的第 2 版中无法做到这一点。现在可以在 API v3 中实现。
在此处查看文档:
https://developer.surveymonkey.com/api/v3/#surveys
例子:
创建一个新调查:
POST /surveys
{
"title": "Example Survey"
}
这将返回调查的survey_id。使用它来创建一个新页面:
POST /surveys/<survey_id>/pages
{
"title": "My First Page",
"description": "Page description",
"position": 1
}
这将返回页面的page_id,用它来创建一个新问题:
POST /surveys/<survey_id>/pages/<page_id>/questions
{
"family": "single_choice",
"subtype": "vertical",
"answers": {
"choices": [
{
"text": "Apple",
"position": 1
},
{
"text": "Orange",
"position": 2
},
{
"text": "Banana",
"position": 3
}
]
},
"headings": [
{
"heading": "What is your favourite fruit?"
}
],
"position": 1
}
或者,如果您已经拥有要创建的整个调查,您可以通过对带有整个有效负载的原始端点执行 POST 来一次创建所有调查:
POST /surveys
{
"title": "Example Survey",
"pages": [
{
"title": "My First Page",
"description": "Page description",
"position": 1,
"questions": [
{
"family": "single_choice",
"subtype": "vertical",
"answers": {
"choices": [
{
"text": "Apple",
"position": 1
},
{
"text": "Orange",
"position": 2
},
{
"text": "Banana",
"position": 3
}
]
},
"headings": [
{
"heading": "What is your favourite fruit?"
}
],
"position": 1
}
]
}
]
}