Surveymonkey 以编程方式创建新调查?

Surveymonkey create new survey programmatically?

如何使用 surveymonkey API 以编程方式创建新调查(带有新问题和选项)?

我能找到的唯一相关 API 方法是 create_flow,它适用于现有的 surveys/templates。我不确定它是否允许修改调查以包含新问题

如前所述,在 API 的第 2 版中无法执行此操作。现在可以在 API v3.

中实现

在此处查看文档:

https://developer.surveymonkey.com/api/v3/#surveys

示例:

创建新调查:

POST /surveys
{
  "title": "Example Survey"
}

这将 return 调查的 survey_id。用它来创建一个新页面:

POST /surveys/<survey_id>/pages
{
  "title": "My First Page",
  "description": "Page description",
  "position": 1
}

这将 return 页面的 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
        }
      ]
    }
  ]
}