Skip to main content
PUT
/
api
/
v3
/
polls
/
{pollId}
/
votes
update poll vote
curl --request PUT \
  --url https://apix.us.amity.co/api/v3/polls/{pollId}/votes \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: <content-type>' \
  --data '
{
  "answerIds": [
    "<string>"
  ]
}
'
import requests

url = "https://apix.us.amity.co/api/v3/polls/{pollId}/votes"

payload = { "answerIds": ["<string>"] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "<content-type>"
}

response = requests.put(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': '<content-type>'},
body: JSON.stringify({answerIds: ['<string>']})
};

fetch('https://apix.us.amity.co/api/v3/polls/{pollId}/votes', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://apix.us.amity.co/api/v3/polls/{pollId}/votes",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'answerIds' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: <content-type>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://apix.us.amity.co/api/v3/polls/{pollId}/votes"

payload := strings.NewReader("{\n \"answerIds\": [\n \"<string>\"\n ]\n}")

req, _ := http.NewRequest("PUT", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "<content-type>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.put("https://apix.us.amity.co/api/v3/polls/{pollId}/votes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "<content-type>")
.body("{\n \"answerIds\": [\n \"<string>\"\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://apix.us.amity.co/api/v3/polls/{pollId}/votes")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = '<content-type>'
request.body = "{\n \"answerIds\": [\n \"<string>\"\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "polls": [
    {
      "pollId": "<string>",
      "userId": "<string>",
      "userInternalId": "64be1f6cb9b4106b5a6bbf3f",
      "userPublicId": "User123",
      "title": "<string>",
      "question": "<string>",
      "answers": [
        {
          "data": "<string>",
          "fileId": "<string>",
          "voteCount": 0,
          "isVotedByUser": false,
          "id": "<string>"
        }
      ],
      "answerType": "<string>",
      "closedAt": "<string>",
      "createdAt": "<string>",
      "isVoted": false,
      "status": "open",
      "closedIn": 123
    }
  ],
  "users": [
    {
      "userId": "<string>",
      "createdAt": "2023-11-07T05:31:56Z",
      "updatedAt": "2023-11-07T05:31:56Z",
      "_id": "<string>",
      "path": "<string>",
      "userInternalId": "<string>",
      "userPublicId": "<string>",
      "roles": [
        "<string>"
      ],
      "permissions": [],
      "displayName": "<string>",
      "profileHandle": "<string>",
      "description": "<string>",
      "avatarFileId": "<string>",
      "avatarCustomUrl": "<string>",
      "flagCount": 123,
      "hashFlag": {
        "bits": 123,
        "hashes": 123,
        "hash": [
          "<string>"
        ]
      },
      "metadata": {},
      "isGlobalBan": true,
      "isBrand": true,
      "isDeleted": true
    }
  ],
  "roles": [
    {
      "roleId": "<string>",
      "updatedAt": "2023-11-07T05:31:56Z",
      "permissions": [
        "<string>"
      ],
      "isDeleted": false,
      "displayName": "<string>",
      "createdAt": "2023-11-07T05:31:56Z"
    }
  ]
}
{
"status": "error",
"code": 400000,
"message": "Bad Request."
}
{
"status": "error",
"code": 400400,
"message": "Poll not found."
}
{
"status": "error",
"code": 500000,
"message": "Unexpected error"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

Authorization
string
required
Content-Type
string
required

Path Parameters

pollId
string
required

Body

application/json

Information to update an existing poll vote.

Required

  • answerIds for updating the poll vote
answerIds
string[]
required

Updated answer IDs for the poll vote

Response

Poll Information

polls
object[]
users
object[]
roles
object[]