Polls

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"}}'

GET /api/polls/:poll_id
get information about a poll with poll_id

GET /api/messages/:message_id/poll
get information about a poll with message_id

Success Response Code: 200

Params

Param name Description
poll_id
optional

id of the poll


Value: Must be a Integer
message_id
optional

id of the messsage


Value: Must be a Integer

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 GET -v --basic -u "emily@socialcast.com:demo" "https://demo.socialcast.com/api/polls/1.json"
curl -X GET -v --basic -u "emily@socialcast.com:demo" "https://demo.socialcast.com/api/messages/431/poll.json"

Examples

GET 
200
{
  "poll": {
    "id": 1,
    "question": "whø & what am I? 1",
    "answers": [
      {
        "id": 1,
        "text": "høme & away 1",
        "response_count": 0
      }
    ],
    "social_object_id": 39,
    "my_response_id": null
  }
}

POST /api/polls/:poll_id/respond
respond to a poll with poll_id

POST /api/messages/:message_id/poll/respond
respond to a poll with message_id

Success Response Code: 201

Params

Param name Description
poll_id
optional

id of the poll which you want to respond


Value: Must be a Integer
message_id
optional

id of the message which contains the poll you want to respond


Value: Must be a Integer
answer_id
required

answer ID to submit


Value: Must be a Integer

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/1/respond.json" -d "answer_id=1"
curl -X POST -v --basic -u "emily@socialcast.com:demo" "https://demo.socialcast.com/api/messages/431/poll/respond.json" -d "answer_id=13"

Examples

POST 
{
  "answer_id": "1"
}
201
{
  "poll": {
    "id": 1,
    "question": "whø & what am I? 1",
    "answers": [
      {
        "id": 1,
        "text": "høme & away 1",
        "response_count": 1
      }
    ],
    "social_object_id": 39,
    "my_response_id": 1
  }
}