Chilkat Online Tools

Swift3 / Zoom API / Create a meeting poll

Back to Collection Items

func chilkatTest() {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    let http = CkoHttp()!
    var success: Bool

    let req = CkoHttpRequest()!
    req.httpVerb = "POST"
    req.path = "/v2/meetings/:meetingId/polls"
    req.contentType = "multipart/form-data"
    req.addParam("title", value: "a")

    req.addParam("poll_type", value: "a3")

    req.addParam("anonymous", value: "a3false")

    req.addParam("questions", value: "a3false[{\"name\":\"ad in ullamco elit\",\"type\":\"rating_scale\",\"show_as_dropdown\":false,\"answer_required\":false,\"answers\":[\"in \",\"do sint ipsum\"],\"right_answers\":[\"deserunt id\"],\"prompts\":[{\"prompt_question\":\"sint ipsum irure\",\"prompt_right_answers\":[\"sit officia\",\"irure est nostrud nul\"]},{\"prompt_question\":\"qui\",\"prompt_right_answers\":[\"veniam\",\"voluptate reprehenderit irure\"]}],\"answer_min_character\":29173071,\"answer_max_character\":27567154,\"case_sensitive\":false,\"rating_min_value\":58887175,\"rating_max_value\":-45787201,\"rating_min_label\":\"ea commodo\",\"rating_max_label\":\"ipsum dolore\"},{\"name\":\"ut eiusmod adipisicing exercitation\",\"type\":\"single\",\"show_as_dropdown\":false,\"answer_required\":false,\"answers\":[\"Excepteur Ut\",\"exercitation voluptate\"],\"right_answers\":[\"occaecat do esse\"],\"prompts\":[{\"prompt_question\":\"laboris eiusmod commodo ipsum ut\",\"prompt_right_answers\":[\"ut Lorem dolor do\",\"ullamco cillum tempor pariatur\"]},{\"prompt_question\":\"officia l\",\"prompt_right_answers\":[\"nulla pariatur\",\"voluptate aliqua sint\"]}],\"answer_min_character\":68878731,\"answer_max_character\":-60270992,\"case_sensitive\":false,\"rating_min_value\":61727066,\"rating_max_value\":-36610809,\"rating_min_label\":\"in ut\",\"rating_max_label\":\"proident officia\"}]")

    req.addHeader("Authorization", value: "Bearer <access_token>")

    var resp: CkoHttpResponse? = http.synchronousRequest("api.zoom.us", port: 443, ssl: true, req: req)
    if http.lastMethodSuccess == false {
        print("\(http.lastErrorText!)")
        return
    }

    let sbResponseBody = CkoStringBuilder()!
    resp!.getBodySb(sbResponseBody)

    let jResp = CkoJsonObject()!
    jResp.loadSb(sbResponseBody)
    jResp.emitCompact = false

    print("Response Body:")
    print("\(jResp.emit()!)")

    var respStatusCode: Int = resp!.statusCode.intValue
    print("Response Status Code = \(respStatusCode)")
    if respStatusCode >= 400 {
        print("Response Header:")
        print("\(resp!.header!)")
        print("Failed.")
        resp = nil
        return
    }

    resp = nil

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "id": "abcdaaaeefffhhh",
    //   "status": "notstart",
    //   "title": "Meeting Usefulness",
    //   "anonymous": false,
    //   "poll_type": 2,
    //   "questions": [
    //     {
    //       "name": "How useful was this meeting?",
    //       "type": "multiple",
    //       "answer_required": false,
    //       "answers": [
    //         "Extremely useful",
    //         "Somewhat useful",
    //         "Not useful at all"
    //       ],
    //       "right_answers": [
    //         "Not useful at all"
    //       ]
    //     }
    //   ]
    // }

    // Sample code for parsing the JSON response...
    // Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    var name: String?
    var v_type: String?
    var answer_required: Bool
    var j: Int
    var count_j: Int
    var strVal: String?

    var id: String? = jResp.string(of: "id")
    var status: String? = jResp.string(of: "status")
    var title: String? = jResp.string(of: "title")
    var anonymous: Bool = jResp.bool(of: "anonymous")
    var poll_type: Int = jResp.int(of: "poll_type").intValue
    var i: Int = 0
    var count_i: Int = jResp.size(ofArray: "questions").intValue
    while i < count_i {
        jResp.i = i
        name = jResp.string(of: "questions[i].name")
        v_type = jResp.string(of: "questions[i].type")
        answer_required = jResp.bool(of: "questions[i].answer_required")
        j = 0
        count_j = jResp.size(ofArray: "questions[i].answers").intValue
        while j < count_j {
            jResp.j = j
            strVal = jResp.string(of: "questions[i].answers[j]")
            j = j + 1
        }

        j = 0
        count_j = jResp.size(ofArray: "questions[i].right_answers").intValue
        while j < count_j {
            jResp.j = j
            strVal = jResp.string(of: "questions[i].right_answers[j]")
            j = j + 1
        }

        i = i + 1
    }


}

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: multipart/form-data"
	--form 'title=a'
	--form 'poll_type=a3'
	--form 'anonymous=a3false'
	--form 'questions=a3false[{"name":"ad in ullamco elit","type":"rating_scale","show_as_dropdown":false,"answer_required":false,"answers":["in ","do sint ipsum"],"right_answers":["deserunt id"],"prompts":[{"prompt_question":"sint ipsum irure","prompt_right_answers":["sit officia","irure est nostrud nul"]},{"prompt_question":"qui","prompt_right_answers":["veniam","voluptate reprehenderit irure"]}],"answer_min_character":29173071,"answer_max_character":27567154,"case_sensitive":false,"rating_min_value":58887175,"rating_max_value":-45787201,"rating_min_label":"ea commodo","rating_max_label":"ipsum dolore"},{"name":"ut eiusmod adipisicing exercitation","type":"single","show_as_dropdown":false,"answer_required":false,"answers":["Excepteur Ut","exercitation voluptate"],"right_answers":["occaecat do esse"],"prompts":[{"prompt_question":"laboris eiusmod commodo ipsum ut","prompt_right_answers":["ut Lorem dolor do","ullamco cillum tempor pariatur"]},{"prompt_question":"officia l","prompt_right_answers":["nulla pariatur","voluptate aliqua sint"]}],"answer_min_character":68878731,"answer_max_character":-60270992,"case_sensitive":false,"rating_min_value":61727066,"rating_max_value":-36610809,"rating_min_label":"in ut","rating_max_label":"proident officia"}]'
https://api.zoom.us/v2/meetings/:meetingId/polls

Postman Collection Item JSON

{
  "name": "Create a meeting poll",
  "request": {
    "auth": {
      "type": "oauth2"
    },
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "multipart/form-data"
      }
    ],
    "body": {
      "mode": "formdata",
      "formdata": [
        {
          "key": "title",
          "value": "a",
          "description": "undefined",
          "type": "text"
        },
        {
          "key": "poll_type",
          "value": "3",
          "description": "undefined",
          "type": "text"
        },
        {
          "key": "anonymous",
          "value": "false",
          "description": "undefined",
          "type": "text"
        },
        {
          "key": "questions",
          "value": "[{\"name\":\"ad in ullamco elit\",\"type\":\"rating_scale\",\"show_as_dropdown\":false,\"answer_required\":false,\"answers\":[\"in \",\"do sint ipsum\"],\"right_answers\":[\"deserunt id\"],\"prompts\":[{\"prompt_question\":\"sint ipsum irure\",\"prompt_right_answers\":[\"sit officia\",\"irure est nostrud nul\"]},{\"prompt_question\":\"qui\",\"prompt_right_answers\":[\"veniam\",\"voluptate reprehenderit irure\"]}],\"answer_min_character\":29173071,\"answer_max_character\":27567154,\"case_sensitive\":false,\"rating_min_value\":58887175,\"rating_max_value\":-45787201,\"rating_min_label\":\"ea commodo\",\"rating_max_label\":\"ipsum dolore\"},{\"name\":\"ut eiusmod adipisicing exercitation\",\"type\":\"single\",\"show_as_dropdown\":false,\"answer_required\":false,\"answers\":[\"Excepteur Ut\",\"exercitation voluptate\"],\"right_answers\":[\"occaecat do esse\"],\"prompts\":[{\"prompt_question\":\"laboris eiusmod commodo ipsum ut\",\"prompt_right_answers\":[\"ut Lorem dolor do\",\"ullamco cillum tempor pariatur\"]},{\"prompt_question\":\"officia l\",\"prompt_right_answers\":[\"nulla pariatur\",\"voluptate aliqua sint\"]}],\"answer_min_character\":68878731,\"answer_max_character\":-60270992,\"case_sensitive\":false,\"rating_min_value\":61727066,\"rating_max_value\":-36610809,\"rating_min_label\":\"in ut\",\"rating_max_label\":\"proident officia\"}]",
          "description": "undefined",
          "type": "text"
        }
      ]
    },
    "url": {
      "raw": "{{baseUrl}}/meetings/:meetingId/polls",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "meetings",
        ":meetingId",
        "polls"
      ],
      "variable": [
        {
          "key": "meetingId",
          "value": "68423085",
          "description": "(Required) The meeting's ID. \n\n When storing this value in your database, you must store it as a **long** format integer and **not** an integer. Meeting IDs can exceed 10 digits."
        }
      ]
    },
    "description": "Polls allow the meeting host to survey attendees. Use this API to create a [poll](https://support.zoom.us/hc/en-us/articles/213756303-Polling-for-Meetings) for a meeting.<br><br>\n\n**Scopes**: `meeting:write:admin` `meeting:write`<br>\n **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Light`<br>\n**Prerequisites**:<br>\n* Host user type must be **Pro** or higher plan.\n* Polling feature must be enabled in the host's account.\n* Meeting must be a scheduled meeting. Instant meetings do not have polling features enabled."
  },
  "response": [
    {
      "name": "**HTTP Status Code:** `201` <br>\nMeeting Poll Created",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "title",
              "value": "fugiat exercitation proident magna ullamco",
              "description": "undefined",
              "type": "text"
            },
            {
              "key": "poll_type",
              "value": "1",
              "description": "undefined",
              "type": "text"
            },
            {
              "key": "anonymous",
              "value": "false",
              "description": "undefined",
              "type": "text"
            },
            {
              "key": "questions",
              "value": "[{\"name\":\"irure ex velit consectetur\",\"type\":\"rating_scale\",\"show_as_dropdown\":false,\"answer_required\":false,\"answers\":[\"commodo in in ad\",\"do officia dolore eu\"],\"right_answers\":[\"laborum officia\"],\"prompts\":[{\"prompt_question\":\"minim in mollit\",\"prompt_right_answers\":[\"in cillum amet\",\"cupida\"]},{\"prompt_question\":\"eiusmod culpa\",\"prompt_right_answers\":[\"irure fugiat\",\"eiusmod et occaecat magna sed\"]}],\"answer_min_character\":93145901,\"answer_max_character\":91006906,\"case_sensitive\":false,\"rating_min_value\":37530130,\"rating_max_value\":-38740448,\"rating_min_label\":\"quis non proident Duis\",\"rating_max_label\":\"irure pariatur nisi\"},{\"name\":\"labore cillum\",\"type\":\"rank_order\",\"show_as_dropdown\":false,\"answer_required\":false,\"answers\":[\"in aliqua cillum\",\"irure fugiat qui et\"],\"right_answers\":[\"dolor in u\"],\"prompts\":[{\"prompt_question\":\"occaecat reprehenderit\",\"prompt_right_answers\":[\"reprehenderit deserunt\",\"c\"]},{\"prompt_question\":\"occaecat velit\",\"prompt_right_answers\":[\"ut mollit eu ipsum\",\"qui et tempor aute\"]}],\"answer_min_character\":72197843,\"answer_max_character\":-2000739,\"case_sensitive\":false,\"rating_min_value\":25766114,\"rating_max_value\":-12152537,\"rating_min_label\":\"adipisicing mollit in et\",\"rating_max_label\":\"Lorem magna non id\"}]",
              "description": "undefined",
              "type": "text"
            }
          ]
        },
        "url": {
          "raw": "{{baseUrl}}/meetings/:meetingId/polls",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "meetings",
            ":meetingId",
            "polls"
          ],
          "variable": [
            {
              "key": "meetingId",
              "value": "68423085",
              "description": "(Required) The meeting's ID. \n\n When storing this value in your database, you must store it as a **long** format integer and **not** an integer. Meeting IDs can exceed 10 digits."
            }
          ]
        }
      },
      "status": "Created",
      "code": 201,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Location",
          "value": "quis officia in reprehenderit",
          "description": "Location of created Meeting Poll"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"id\": \"abcdaaaeefffhhh\",\n \"status\": \"notstart\",\n \"title\": \"Meeting Usefulness\",\n \"anonymous\": false,\n \"poll_type\": 2,\n \"questions\": [\n  {\n   \"name\": \"How useful was this meeting?\",\n   \"type\": \"multiple\",\n   \"answer_required\": false,\n   \"answers\": [\n    \"Extremely useful\",\n    \"Somewhat useful\",\n    \"Not useful at all\"\n   ],\n   \"right_answers\": [\n    \"Not useful at all\"\n   ]\n  }\n ]\n}"
    },
    {
      "name": "**HTTP Status Code:** `400` **Bad Request** <br>\n **Error Code:** `4400` <br>\n* Meeting polls disabled. To enable this feature, enable the \"Meeting Polls/Quizzes\" setting in the Zoom web portal's \"Settings\" interface. \n* Advanced meeting polls disabled. T",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "title",
              "value": "fugiat exercitation proident magna ullamco",
              "description": "undefined",
              "type": "text"
            },
            {
              "key": "poll_type",
              "value": "1",
              "description": "undefined",
              "type": "text"
            },
            {
              "key": "anonymous",
              "value": "false",
              "description": "undefined",
              "type": "text"
            },
            {
              "key": "questions",
              "value": "[{\"name\":\"irure ex velit consectetur\",\"type\":\"rating_scale\",\"show_as_dropdown\":false,\"answer_required\":false,\"answers\":[\"commodo in in ad\",\"do officia dolore eu\"],\"right_answers\":[\"laborum officia\"],\"prompts\":[{\"prompt_question\":\"minim in mollit\",\"prompt_right_answers\":[\"in cillum amet\",\"cupida\"]},{\"prompt_question\":\"eiusmod culpa\",\"prompt_right_answers\":[\"irure fugiat\",\"eiusmod et occaecat magna sed\"]}],\"answer_min_character\":93145901,\"answer_max_character\":91006906,\"case_sensitive\":false,\"rating_min_value\":37530130,\"rating_max_value\":-38740448,\"rating_min_label\":\"quis non proident Duis\",\"rating_max_label\":\"irure pariatur nisi\"},{\"name\":\"labore cillum\",\"type\":\"rank_order\",\"show_as_dropdown\":false,\"answer_required\":false,\"answers\":[\"in aliqua cillum\",\"irure fugiat qui et\"],\"right_answers\":[\"dolor in u\"],\"prompts\":[{\"prompt_question\":\"occaecat reprehenderit\",\"prompt_right_answers\":[\"reprehenderit deserunt\",\"c\"]},{\"prompt_question\":\"occaecat velit\",\"prompt_right_answers\":[\"ut mollit eu ipsum\",\"qui et tempor aute\"]}],\"answer_min_character\":72197843,\"answer_max_character\":-2000739,\"case_sensitive\":false,\"rating_min_value\":25766114,\"rating_max_value\":-12152537,\"rating_min_label\":\"adipisicing mollit in et\",\"rating_max_label\":\"Lorem magna non id\"}]",
              "description": "undefined",
              "type": "text"
            }
          ]
        },
        "url": {
          "raw": "{{baseUrl}}/meetings/:meetingId/polls",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "meetings",
            ":meetingId",
            "polls"
          ],
          "variable": [
            {
              "key": "meetingId",
              "value": "68423085",
              "description": "(Required) The meeting's ID. \n\n When storing this value in your database, you must store it as a **long** format integer and **not** an integer. Meeting IDs can exceed 10 digits."
            }
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "**Error Code:** `404` <br>\nMeeting not found",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "title",
              "value": "fugiat exercitation proident magna ullamco",
              "description": "undefined",
              "type": "text"
            },
            {
              "key": "poll_type",
              "value": "1",
              "description": "undefined",
              "type": "text"
            },
            {
              "key": "anonymous",
              "value": "false",
              "description": "undefined",
              "type": "text"
            },
            {
              "key": "questions",
              "value": "[{\"name\":\"irure ex velit consectetur\",\"type\":\"rating_scale\",\"show_as_dropdown\":false,\"answer_required\":false,\"answers\":[\"commodo in in ad\",\"do officia dolore eu\"],\"right_answers\":[\"laborum officia\"],\"prompts\":[{\"prompt_question\":\"minim in mollit\",\"prompt_right_answers\":[\"in cillum amet\",\"cupida\"]},{\"prompt_question\":\"eiusmod culpa\",\"prompt_right_answers\":[\"irure fugiat\",\"eiusmod et occaecat magna sed\"]}],\"answer_min_character\":93145901,\"answer_max_character\":91006906,\"case_sensitive\":false,\"rating_min_value\":37530130,\"rating_max_value\":-38740448,\"rating_min_label\":\"quis non proident Duis\",\"rating_max_label\":\"irure pariatur nisi\"},{\"name\":\"labore cillum\",\"type\":\"rank_order\",\"show_as_dropdown\":false,\"answer_required\":false,\"answers\":[\"in aliqua cillum\",\"irure fugiat qui et\"],\"right_answers\":[\"dolor in u\"],\"prompts\":[{\"prompt_question\":\"occaecat reprehenderit\",\"prompt_right_answers\":[\"reprehenderit deserunt\",\"c\"]},{\"prompt_question\":\"occaecat velit\",\"prompt_right_answers\":[\"ut mollit eu ipsum\",\"qui et tempor aute\"]}],\"answer_min_character\":72197843,\"answer_max_character\":-2000739,\"case_sensitive\":false,\"rating_min_value\":25766114,\"rating_max_value\":-12152537,\"rating_min_label\":\"adipisicing mollit in et\",\"rating_max_label\":\"Lorem magna non id\"}]",
              "description": "undefined",
              "type": "text"
            }
          ]
        },
        "url": {
          "raw": "{{baseUrl}}/meetings/:meetingId/polls",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "meetings",
            ":meetingId",
            "polls"
          ],
          "variable": [
            {
              "key": "meetingId",
              "value": "68423085",
              "description": "(Required) The meeting's ID. \n\n When storing this value in your database, you must store it as a **long** format integer and **not** an integer. Meeting IDs can exceed 10 digits."
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}