You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
7.9 KiB
7.9 KiB
Poll API
Base endpoint is: /ocs/v2.php/apps/spreed/api/v1
Create a poll in a conversation
- Method:
POST - Endpoint:
/poll/{token} - Data:
| field | type | Description |
|---|---|---|
question |
string | The question of the poll |
options |
string[] | Array of strings with the voting options |
resultMode |
int | The result and voting mode of the poll, 0 means participants can immediatelly see the result and who voted for which option. 1 means the result is hidden until the poll is closed and then only the summary is published. |
maxVotes |
int | Maximum amount of options a participant can vote for |
- Response:
-
Status code:
201 Created400 Bad RequestWhen the room is a one-to-one conversation400 Bad RequestWhen the question or the options were too long or invalid (not strings)403 ForbiddenWhen the conversation is read-only403 ForbiddenWhen the actor does not have chat permissions404 Not FoundWhen the conversation could not be found for the participant412 Precondition FailedWhen the lobby is active and the user is not a moderator
-
Data:
See Poll data
-
Get state or result of a poll
-
Method:
GET -
Endpoint:
/poll/{token}/{pollId} -
Response:
-
Status code:
201 Created400 Bad RequestIn case of any other error404 Not FoundWhen the conversation could not be found for the participant404 Not FoundWhen the poll id could not be found in the conversation412 Precondition FailedWhen the lobby is active and the user is not a moderator
-
Data:
See Poll data
-
Vote on a poll
- Method:
POST - Endpoint:
/poll/{token}/{pollId} - Data:
| field | type | Description |
|---|---|---|
optionIds |
int[] | The option IDs the participant wants to vote for |
- Response:
-
Status code:
201 Created400 Bad RequestWhen an option id is invalid400 Bad RequestWhen too many options were voted404 Not FoundWhen the conversation could not be found for the participant404 Not FoundWhen the poll id could not be found in the conversation412 Precondition FailedWhen the lobby is active and the user is not a moderator
-
Data:
See Poll data
-
Close a poll
-
Method:
DELETE -
Endpoint:
/poll/{token}/{pollId} -
Response:
-
Status code:
200 OK400 Bad RequestWhen the poll is already closed403 ForbiddenWhen the participant is not the author of the poll or a moderator404 Not FoundWhen the conversation could not be found for the participant404 Not FoundWhen the poll id could not be found in the conversation412 Precondition FailedWhen the lobby is active and the user is not a moderator
-
Data:
See Poll data
-
Poll data
!!! note
Due to the structure of the `votes` array the response is not valid in XML.
It is therefor recommended to use `format=json` or send the `Accept: application/json` header,
to receive a JSON response.
| field | type | Description |
|---|---|---|
id |
int | ID of the poll |
question |
string | The question of the poll |
options |
string[] | The options participants can vote for |
votes |
int[] | Map with 'option-' + optionId => number of votes (only available for when the actor voted on public poll or the poll is closed) |
actorType |
string | Actor type of the poll author (see Constants - Attendee types) |
actorId |
string | Actor ID identifying the poll author |
actorDisplayName |
string | Display name of the poll author |
status |
int | Status of the poll (see Constants - Poll status) |
resultMode |
int | Result mode of the poll (see Constants - Poll mode) |
maxVotes |
int | Maximum amount of options a user can vote for, 0 means unlimited |
votedSelf |
int[] | Array of option ids the participant voted for |
numVoters |
int | The number of unique voters that voted (only available when the actor voted on public poll or the poll is closed unless for the creator and moderators) |
details |
array[] | Detailed list who voted for which option (only available for public closed polls), see Details below |
Details
| field | type | Description |
|---|---|---|
| actorType | string | The actor type of the participant that voted (see Constants - Attendee types) |
| actorId | string | The actor id of the participant that voted |
| actorDisplayName | string | The display name of the participant that voted |
| optionId | int | The option that was voted for |