Creates a new poll. The poll and all its options will be assigned valid IDs and option indices by the server. Options must be passed as an array of strings for the options' texts. The order of the options will be kept.
POST
/api/pollsAuthorizations
api_key
Type: API Key (header: X-CSRF-Token)
Request Body
JSON
{
"name": "Test poll",
"description": "This is a test poll",
"startDate": "2105-01-01 01:23:45",
"endDate": "2152-01-01 12:34:56",
"regionId": 1,
"scope": 1,
"type": 1,
"options": null,
"notifyVoters": true,
"shuffleOptions": true
}
Responses
Success
Authorization
api_key
Body
cURL
curl -X POST \
'http://localhost/api/polls' \
-H "api_key: X-CSRF-Token" \
-H "Content-Type: application/json" \
--data '{
"name": "Test poll",
"description": "This is a test poll",
"startDate": "2105-01-01 01:23:45",
"endDate": "2152-01-01 12:34:56",
"regionId": 1,
"scope": 1,
"type": 1,
"options": null,
"notifyVoters": true,
"shuffleOptions": true
}'
Samples
cURL
curl -X POST http://localhost/api/polls
JavaScript
fetch("http://localhost/api/polls", { method: "POST" })
.then(response => response.json())
.then(data => console.log(data));
PHP
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost/api/polls");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
Python
import requests
response = requests.post("http://localhost/api/polls")
print(response.json())