如何使用surveymonkey API以编程方式创建新调查(包含新问题和选项)?
我能找到的唯一相关API方法是create_flow,它与现有的调查/模板一起使用。我不确定它是否允许修改调查以包含新问题
答案 0 :(得分:2)
As mentioned, there was no way to do this in version 2 of the API. This is now possible in API v3.
See the docs here:
https://developer.surveymonkey.com/api/v3/#surveys
Example:
Create a new survey:
POST /surveys
{
"title": "Example Survey"
}
This will return the survey_id of the survey. Use it to create a new page:
POST /surveys/<survey_id>/pages
{
"title": "My First Page",
"description": "Page description",
"position": 1
}
This will return the page_id of the page, use it to create a new question:
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
}
Alternatively, if you already have the entire survey you want to create, you can create it all at once by doing a POST to the original endpoint with the entire payload:
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
}
]
}
]
}