Poll
| Poll | |
| Resource | |
| Poll | You can create, retrieve, delete, or vote on a poll on the fantasy league’s message board. |
| HTTP Methods | |
| GET | Retrieve a Poll |
| POST | Create a new Poll. |
| PUT | Vote on a Poll By ID. |
| DELETE | Delete a Poll By ID. |
| Example | |
| Retrieve a Poll | GET |
| Create a Poll | POST |
| Vote for a Poll | PUT |
| Delete a Poll | DELETE |
| XML field definitions | |
| /poll | A container element for a Poll. |
| /poll/@id | ID of the poll. |
| /poll/ | A container element for possible answers for a Poll. |
| /poll/ | An container element for an answer for a Poll. |
| /poll/ | ID of the answer. |
| /poll/ | Text Value of the answer. |
| /poll/ | Number of votes for the answer (exists only when user requesting the poll has answered the Poll). |
| /poll/ | Name of the Author of the Poll. |
| /poll/ | Poll Question. |
| /poll/ | Subject of the Poll. |
| /poll/ | Timestamp when the Poll was created in UNIX timestamp format. |
| /poll/ | Total Number of views for the Poll. |
Poll
Description
You can create, retrieve, delete, or vote on a poll on the fantasy league’s message board.
The poll information includes the poll ID, author, timestamp, subject, total views, question, a list of answers and if the user requesting the poll has already voted, the number of votes for each answer.
GET
Retrieve a Poll
URL
http://api.cbssports.com
Parameters
| response_format | (optional) Specifies the format in which the requested resource should be returned. Valid values are XML and JSON. The default is XML. |
| id | The ID of the poll to be returned. You can get poll IDs by requesting the Message List resource. The poll ID is found in the field /message_list/message/@id where </message_lsit/message/type> is ‘poll’. |
Response
An XML or JSON encoding of the requested poll. (See Examples below.)
POST
Create a new Poll. A Poll can have a maximum of 8 answers.
URL
http://api.cbssports.com
Parameters
| response_format | (optional) Specifies the format in which the requested resource should be returned. Valid values are XML and JSON. The default is XML. |
Body
To be sent as payload=JSON
payload={"subject": "<subject>", "question": "<question>", "answers": [ "<answer1>", "<answer2>", ... , "<answer8>" ]}where
- <subject> = Subject of the new poll.
- <question> = Question for the poll.
- <answer1> through <answer8> = Answers for the question.
Response
An XML or JSON encoding of the new poll. (See Examples below.)
PUT
Vote on a Poll By ID.
URL
http://api.cbssports.com
Parameters
| response_format | (optional) Specifies the format in which the requested resource should be returned. Valid values are XML and JSON. The default is XML. |
Body
To be sent as payload=JSON
payload={"id": "<poll_id>", "answer_id": "<answer_id>"}where
- <poll_id> = ID of the poll.
- <answer_id> = ID of the answer that is the user’s vote.
Response
An XML or JSON encoding of the poll. (See Examples below.)
DELETE
Delete a Poll By ID. Only commissioners can delete Polls.
URL
http://api.cbssports.com
Parameters
| response_format | (optional) Specifies the format in which the requested resource should be returned. Valid values are XML and JSON. The default is XML. |
| id | ID of the poll to be deleted |
Response
One of the following HTTP Status Codes
- 204 if Poll was successfully deleted
- 400 if Poll was not found or user trying to delete is not a commissioner
Retrieve a Poll
Method
GET
Sample URL
http://api.cbssports.com/fantasy/league/message-board/poll?id={poll_id}XML Response
<?xml version="1.0"?>
<result uriAlias="/league/message-board/poll" uri="/league/message-board/poll" statusCode="200" statusMessage="OK">
<body>
<poll id="1338325928-765082CA-88C1-11E1-B180-AB4E3A6FB734">
<question>Test Question?</question>
<views>0</views>
<timestamp>1338325928</timestamp>
<subject>Here is the test subject for the poll.</subject>
<author>Poll Author Name</author>
<answers>
<answer id="1">
<value>Answer 1</value>
<votes>0</votes>
</answer>
<answer id="2">
<value>Answer 2</value>
<votes>1</votes>
</answer>
<answer id="3">
<value>Answer 3</value>
<votes>0</votes>
</answer>
<answer id="4">
<value>Answer 4</value>
<votes>0</votes>
</answer>
<answer id="5">
<value>Answer 5</value>
<votes>0</votes>
</answer>
</answers>
</poll>
</body>
</result>JSON Response
{
"body" : {
"poll" : {
"question" : "Test Question?",
"views" : 0,
"timestamp" : "1338325928",
"subject" : "Here is the test subject for the poll.",
"author" : "Poll Author Name",
"id" : "1338325928-765082CA-88C1-11E1-B180-AB4E3A6FB734",
"answers" : [
{
"value" : "Answer 1",
"id" : 1,
"votes" : 0
},
{
"value" : "Answer 2",
"id" : 2,
"votes" : 1
},
{
"value" : "Answer 3",
"id" : 3,
"votes" : 0
},
{
"value" : "Answer 4",
"id" : 4,
"votes" : 0
},
{
"value" : "Answer 5",
"id" : 5,
"votes" : 0
}
]
}
},
"uriAlias" : "/league/message-board/poll",
"statusMessage" : "OK",
"uri" : "/league/message-board/poll",
"statusCode" : 200
}Create a Poll
Method
POST
Sample URL
http://api.cbssports.com/fantasy/league/message-board/poll
Body
payload={"subject": "New Poll Subject", "question": "Poll Question", "answers": [ "Answer 1", "Answer 2", "Answer 3" ]}XML Response
<?xml version="1.0"?>
<result uriAlias="/league/message-board/poll" uri="/league/message-board/poll" statusCode="200" statusMessage="OK">
<body>
<poll id="1338326345-765082CA-88C1-11E1-B180-AB4E3A6FB734">
<question>Poll Question</question>
<views>0</views>
<timestamp>1338326345</timestamp>
<subject>New Poll Subject</subject>
<author>Poll Author Name</author>
<answers>
<answer id="1">
<value>Answer 1</value>
</answer>
<answer id="2">
<value>Answer 2</value>
</answer>
<answer id="3">
<value>Answer 3</value>
</answer>
</answers>
</poll>
</body>
</result>JSON Response
{
"body" : {
"poll" : {
"question" : "Poll Question",
"views" : 0,
"timestamp" : "1338326345",
"subject" : "New Poll Subject",
"author" : "Poll Author Name",
"id" : "1338326345-765082CA-88C1-11E1-B180-AB4E3A6FB734",
"answers" : [
{
"value" : "Answer 1",
"id" : 1
},
{
"value" : "Answer 2",
"id" : 2
},
{
"value" : "Answer 3",
"id" : 3
}
]
}
},
"uriAlias" : "/league/message-board/poll",
"statusMessage" : "OK",
"uri" : "/league/message-board/poll",
"statusCode" : 200
}Vote for a Poll
Method
PUT
Sample URL
http://api.cbssports.com/fantasy/league/message-board/poll
Body
payload={"id": "1338326345-765082CA-88C1-11E1-B180-AB4E3A6FB734", "answer_id": 1}XML Response
<?xml version="1.0"?>
<result uriAlias="/league/message-board/poll" uri="/league/message-board/poll" statusCode="200" statusMessage="OK">
<body>
<poll id="1338326345-765082CA-88C1-11E1-B180-AB4E3A6FB734">
<question>Poll Question</question>
<views>0</views>
<timestamp>1338326345</timestamp>
<subject>New Poll Subject</subject>
<author>Poll Author Name</author>
<answers>
<answer id="1">
<value>Answer 1</value>
<votes>0</votes>
</answer>
<answer id="2">
<value>Answer 2</value>
<votes>1</votes>
</answer>
<answer id="3">
<value>Answer 3</value>
<votes>0</votes>
</answer>
</answers>
</poll>
</body>
</result>JSON Response
{
"body" : {
"poll" : {
"question" : "Poll Question",
"views" : 0,
"timestamp" : "1338326345",
"subject" : "New Poll Subject",
"author" : "Poll Author Name",
"id" : "1338326345-765082CA-88C1-11E1-B180-AB4E3A6FB734",
"answers" : [
{
"value" : "Answer 1",
"id" : 1,
"votes" : 0
},
{
"value" : "Answer 2",
"id" : 2,
"votes" : 1
},
{
"value" : "Answer 3",
"id" : 3,
"votes" : 0
}
]
}
},
"uriAlias" : "/league/message-board/poll",
"statusMessage" : "OK",
"uri" : "/league/message-board/poll",
"statusCode" : 200
}