curl --request POST \
--url https://pollunit.com/api/v1/polls/{poll_id}/voters \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"voter": {
"user_name": "Jack",
"additional_attributes": {},
"terms": true,
"privacy_policy": true
}
}
'import requests
url = "https://pollunit.com/api/v1/polls/{poll_id}/voters"
payload = { "voter": {
"user_name": "Jack",
"additional_attributes": {},
"terms": True,
"privacy_policy": True
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
voter: {
user_name: 'Jack',
additional_attributes: {},
terms: true,
privacy_policy: true
}
})
};
fetch('https://pollunit.com/api/v1/polls/{poll_id}/voters', 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://pollunit.com/api/v1/polls/{poll_id}/voters",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'voter' => [
'user_name' => 'Jack',
'additional_attributes' => [
],
'terms' => true,
'privacy_policy' => true
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://pollunit.com/api/v1/polls/{poll_id}/voters"
payload := strings.NewReader("{\n \"voter\": {\n \"user_name\": \"Jack\",\n \"additional_attributes\": {},\n \"terms\": true,\n \"privacy_policy\": true\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://pollunit.com/api/v1/polls/{poll_id}/voters")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"voter\": {\n \"user_name\": \"Jack\",\n \"additional_attributes\": {},\n \"terms\": true,\n \"privacy_policy\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://pollunit.com/api/v1/polls/{poll_id}/voters")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"voter\": {\n \"user_name\": \"Jack\",\n \"additional_attributes\": {},\n \"terms\": true,\n \"privacy_policy\": true\n }\n}"
response = http.request(request)
puts response.read_body{
"message": "Complete payment for voter",
"url": "<string>"
}{
"id": "<string>",
"user_name": "<string>",
"changed_by_admin": true,
"complete": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"fraudulent": true,
"paid": true,
"required_option_votes_complete": true,
"privacy_policy_accepted": true,
"terms_accepted": true
}{
"error": "Unauthorized"
}{
"error": "Not Found"
}{
"error": "Unprocessable Entity",
"errors": {}
}Create participant
Adds a participant to the poll, which is the object the votes of one person belong to. A private token creates the participant on behalf of its user, a public token creates it anonymously and the X-POLLUNIT-USER-IDENTIFIER header decides which anonymous user it belongs to. The call is idempotent for one user: a repeated request updates the existing participant instead of adding a second one. The poll has to be votable, and its participant limit and access restrictions apply.
curl --request POST \
--url https://pollunit.com/api/v1/polls/{poll_id}/voters \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"voter": {
"user_name": "Jack",
"additional_attributes": {},
"terms": true,
"privacy_policy": true
}
}
'import requests
url = "https://pollunit.com/api/v1/polls/{poll_id}/voters"
payload = { "voter": {
"user_name": "Jack",
"additional_attributes": {},
"terms": True,
"privacy_policy": True
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
voter: {
user_name: 'Jack',
additional_attributes: {},
terms: true,
privacy_policy: true
}
})
};
fetch('https://pollunit.com/api/v1/polls/{poll_id}/voters', 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://pollunit.com/api/v1/polls/{poll_id}/voters",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'voter' => [
'user_name' => 'Jack',
'additional_attributes' => [
],
'terms' => true,
'privacy_policy' => true
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://pollunit.com/api/v1/polls/{poll_id}/voters"
payload := strings.NewReader("{\n \"voter\": {\n \"user_name\": \"Jack\",\n \"additional_attributes\": {},\n \"terms\": true,\n \"privacy_policy\": true\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://pollunit.com/api/v1/polls/{poll_id}/voters")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"voter\": {\n \"user_name\": \"Jack\",\n \"additional_attributes\": {},\n \"terms\": true,\n \"privacy_policy\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://pollunit.com/api/v1/polls/{poll_id}/voters")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"voter\": {\n \"user_name\": \"Jack\",\n \"additional_attributes\": {},\n \"terms\": true,\n \"privacy_policy\": true\n }\n}"
response = http.request(request)
puts response.read_body{
"message": "Complete payment for voter",
"url": "<string>"
}{
"id": "<string>",
"user_name": "<string>",
"changed_by_admin": true,
"complete": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"fraudulent": true,
"paid": true,
"required_option_votes_complete": true,
"privacy_policy_accepted": true,
"terms_accepted": true
}{
"error": "Unauthorized"
}{
"error": "Not Found"
}{
"error": "Unprocessable Entity",
"errors": {}
}Authorizations
Headers
Your own identification of the user on whose behalf the request is made, any string. The user identifiers should not be guessable and stay secret, otherwise users could get access to other users' contents. Only used with a public API token: the created or changed object belongs to that anonymous user instead of the token owner, which keeps the user in control of it in later requests with the same identifier.
Query Parameters
Body
Response
voting fee has to be paid