POST /api/polls

create a new poll without a message

Also see messages#create to bind a poll to a message.

Success Response Code: 201

Params

Param name Description
poll
required

Value: Must be a Hash
poll[question]
required

question being asked by the poll


Value: Must be a String
poll[poll_answers_attributes]
required

answers that go with the question as well as an integer representing the answer's order within a poll


Value: Must be a Hash

Response Fields

poll[id] unique ID for the poll Integer
poll[question] question poll is asking String
poll[social_object_id] social object associated with this poll Integer
poll[my_response_id] if requesting user has answered the poll, id of their response Integer
poll[answers] potential answers to this poll Array<PollAnswer>
answer[id] answer's ID Integer
answer[text] text to display with the answer String
answer[response_count] number of votes so far this answer Integer

Example Curl Commands

curl -X POST -v --basic -u "emily@socialcast.com:demo" https://demo.socialcast.com/api/polls.json -H"Content-Type: application/json" -d'{"poll":{"question":"Hands up, who likes me?","poll_answers_attributes":{"1":{"answer":"YES!"},"2":{"answer":"You are OK"},"3":{"answer":"Absolutely not"}}}}'
#binding the created poll to a message
curl -X POST -v --basic -u "emily@socialcast.com:demo" https://demo.socialcast.com/api/messages.json -H "Content-Type: application/json" -d '{"message":{"poll_id":"5", "body":"creating a message with poll"}}'