Enter Contest

From ePrize Developers Wiki

(Difference between revisions)
Jump to: navigation, search
Current revision (20:02, 13 August 2013) (edit) (undo)
 
(7 intermediate revisions not shown.)
Line 1: Line 1:
-
==== Entering a Contest ====
+
{{RESTfulAPI
 +
|crumbs=[[API Home Page]] :: [[Contest API|Contest]]
 +
|summary=Create a contest entry associated with this profile, specifying basic entry metadata such as a description and category. The [[API Key|API key]] will be preconfigured to expect a certain type of entry type (essay content, or binary image data). For binary image submissions, the form must be sent using Content-Type: multipart/form-data
 +
|resource=/v1/{apikey}/contest/entry
 +
|methods=POST
 +
|resourceargs='''apikey''': Your [[API Key]].
 +
|paramsrequired='''body''': for an essay, this is the content of the entry
-
Blank entry:
+
'''photo''': photo URL retrieved from [[Photo Upload Key]]
-
$ curl -i -X POST -H "Accept: text/xml" \
+
'''title''': entry title
-
-dprofile=http://127.0.0.1:10001/v1/solution/contestv2v2/profile/1.5J4L55FNLN2CZZDV \
+
 
-
http://test.url.eprize.com/v1/eprize/ews12/contest/entry
+
'''category''': category to be entered into
-
+
 
-
HTTP 400 (Bad Request)
+
'''description''': description of entry (usually has a character or word length associated)
-
Cache-Control: no-cache
+
 
-
Connection: close
+
'''original_work''': send 'yes' after the user has agreed this is his own work
-
Date: Mon, 12 Jul 2010 01:43:00 GMT
+
 
-
Pragma: no-cache
+
'''official_rules''': send 'yes' after the user agrees his entry conforms to the rules of the contest.
-
Server: POE HTTPD Component/0.09 (5.008008)
+
 
-
Content-Length: 479
+
''Note: other fields may be required depending on the configuration of your [[API Key]]''
-
Content-Type: text/xml; charset=utf-8
+
}}
-
Expires: Fri, 23 Jul 2010 21:34:45 GMT
+
{{RESTfulExample
-
+
|title=Submitting a blank entry
-
<?xml version="1.0" encoding="UTF-8" ?>
+
|summary=Demonstrates validation errors on missing parameters
 +
|request=profile: http://{client}.api.promo.eprize.com/v1/{apikey}/profile/{uid}.{webkey}
 +
|responsecode=400 Bad Request
 +
|response=<?xml version="1.0" encoding="UTF-8" ?>
<result>
<result>
<input_error>
<input_error>
Line 40: Line 49:
</input_error>
</input_error>
</result>
</result>
 +
|extranotes=The {profile} value that is seen in the request of this call is the canonical URL of the profile that the entry is associated with.
 +
}}
-
Successful entry:
+
{{RESTfulExample
-
 
+
|title=Submitting a entry successfully
-
$ curl -i -X POST -H "Accept: text/xml" \
+
|request=profile: http://{client}.api.promo.eprize.com/v1/{apikey}/profile/{uid}.{webkey}
-
-dprofile=http://127.0.0.1:10001/v1/solution/contestv2v2/profile/1.5J4L55FNLN2CZZDV \
+
body: "this is the body of my essay"
-
-dbody="this is the body of my essay" \
+
title: "this is the title of my essay"
-
-dtitle="this is the title of my essay" \
+
original_work: yes
-
-doriginal_work=yes \
+
official_rules: yes
-
-dofficial_rules=yes \
+
category: 1
-
-dcategory=1 \
+
|responsecode=201 Created
-
http://test.url.eprize.com/v1/eprize/ews12/contest/entry
+
|responseloc=/v1/{apikey}/contest/entry/{entryid}
-
+
|response=<?xml version="1.0" encoding="UTF-8" ?>
-
HTTP 201 (Created)
+
-
Cache-Control: no-cache
+
-
Connection: close
+
-
Date: Fri, 23 Jul 2010 21:41:43 GMT
+
-
Pragma: no-cache
+
-
Location: http://127.0.0.1:10001/v1/solution/contestv2/contest/entry/1
+
-
Server: POE HTTPD Component/0.09 (5.008008)
+
-
Content-Length: 533
+
-
Content-Type: text/xml; charset=utf-8
+
-
Expires: Fri, 23 Jul 2010 21:41:43 GMT
+
-
+
-
<?xml version="1.0" encoding="UTF-8" ?>
+
<result>
<result>
<entry>
<entry>
Line 82: Line 81:
</entry>
</entry>
</result>
</result>
-
 
+
|extranotes=The {profile} value that is seen in the request of this call is the canonical URL of the profile that the entry is associated with.
-
Fetch entry:
+
}}
-
 
+
-
$ curl -i -X GET -H "Accept: text/xml" \
+
-
http://test.url.eprize.com/v1/eprize/ews12/contestv2/contest/entry/1
+
-
+
-
HTTP 200 (OK)
+
-
Cache-Control: public
+
-
Connection: close
+
-
Date: Fri, 23 Jul 2010 21:43:40 GMT
+
-
Server: POE HTTPD Component/0.09 (5.008008)
+
-
Content-Length: 533
+
-
Content-Type: text/xml; charset=utf-8
+
-
Expires: Fri, 23 Jul 2010 21:53:40 GMT
+
-
+
-
<?xml version="1.0" encoding="UTF-8" ?>
+
-
<result>
+
-
<entry>
+
-
<body>this is the body of my essay</body>
+
-
<category>1</category>
+
-
<city>PLEASANT RIDGE</city>
+
-
<description></description>
+
-
<entry_id>1</entry_id>
+
-
<entry_state>approved</entry_state>
+
-
<first_name>Todd</first_name>
+
-
<last_name>C</last_name>
+
-
<rating_ave>0.000</rating_ave>
+
-
<rating_count>0</rating_count>
+
-
<state>MI</state>
+
-
<title>this is the title of my essay</title>
+
-
<views>0</views>
+
-
<votes>0</votes>
+
-
</entry>
+
-
</result>
+
-
 
+
-
Rate a contest entry with an invalid rating:
+
-
 
+
-
$ curl -i -X POST -H "Accept: text/xml" \
+
-
-dprofile=http://127.0.0.1:10001/v1/solution/contestv2v2/profile/1.5J4L55FNLN2CZZDV \
+
-
-drating=h \
+
-
http://127.0.0.1:10001/v1/solution/contestv2/contest/entry/1/rate
+
-
+
-
HTTP 400 (Bad Request)
+
-
Cache-Control: no-cache
+
-
Connection: close
+
-
Date: Thu, 01 Apr 2010 04:00:00 GMT
+
-
Pragma: no-cache
+
-
Server: POE HTTPD Component/0.09 (5.008008)
+
-
Content-Length: 147
+
-
Content-Type: text/xml; charset=utf-8
+
-
Expires: Mon, 26 Jul 2010 16:56:20 GMT
+
-
+
-
<?xml version="1.0" encoding="UTF-8" ?>
+
-
<result>
+
-
<input_error>
+
-
<name>rating</name>
+
-
<error>VALIDATION</error>
+
-
</input_error>
+
-
</result>
+
-
 
+
-
Rate an entry successfully:
+
-
 
+
-
$ curl -i -X POST -H "Accept: text/xml" \
+
-
-dprofile=http://127.0.0.1:10001/v1/solution/contestv2v2/profile/1.5J4L55FNLN2CZZDV \
+
-
-drating=1 \
+
-
http://127.0.0.1:10001/v1/solution/contestv2/contest/entry/1/rate
+
-
+
-
HTTP 200 (OK)
+
-
Cache-Control: no-cache
+
-
Connection: close
+
-
Date: Thu, 01 Apr 2010 04:00:00 GMT
+
-
Pragma: no-cache
+
-
Server: POE HTTPD Component/0.09 (5.008008)
+
-
Content-Length: 502
+
-
Content-Type: text/xml; charset=utf-8
+
-
Expires: Mon, 26 Jul 2010 16:56:54 GMT
+
-
+
-
<?xml version="1.0" encoding="UTF-8" ?>
+
-
<result>
+
-
<entry>
+
-
<body>this is the body of my essay</body>
+
-
<category></category>
+
-
<city></city>
+
-
<description></description>
+
-
<entry_id></entry_id>
+
-
<entry_state>approved</entry_state>
+
-
<first_name></first_name>
+
-
<last_name></last_name>
+
-
<rating_ave>0.667</rating_ave>
+
-
<rating_count>3</rating_count>
+
-
<state></state>
+
-
<title>this is the title of my essay</title>
+
-
<views>0</views>
+
-
<votes>0</votes>
+
-
</entry>
+
-
</result>
+
-
 
+
-
Already reached rating limit:
+
-
 
+
-
$ curl -i -X POST -H "Accept: text/xml" \
+
-
-dprofile=http://127.0.0.1:10001/v1/solution/contestv2v2/profile/1.5J4L55FNLN2CZZDV \
+
-
-drating=1 \
+
-
http://127.0.0.1:10001/v1/solution/contestv2/contest/entry/1/rate
+
-
+
-
HTTP 400 (Bad Request)
+
-
Cache-Control: no-cache
+
-
Connection: close
+
-
Date: Thu, 01 Apr 2010 04:00:00 GMT
+
-
Pragma: no-cache
+
-
Server: POE HTTPD Component/0.09 (5.008008)
+
-
Content-Length: 144
+
-
Content-Type: text/xml; charset=utf-8
+
-
Expires: Mon, 26 Jul 2010 16:57:31 GMT
+
-
+
-
<?xml version="1.0" encoding="UTF-8" ?>
+
-
<result>
+
-
<input_error>
+
-
<name>rating</name>
+
-
<error>LIMITED</error>
+
-
</input_error>
+
-
</result>
+
-
 
+
-
Rating timeout:
+
-
 
+
-
$ curl -i -X POST -H "Accept: text/xml" \
+
-
-dprofile=http://127.0.0.1:10001/v1/solution/contestv2v2/profile/1.5J4L55FNLN2CZZDV \
+
-
-drating=1 \
+
-
http://127.0.0.1:10001/v1/solution/contestv2/contest/entry/1/rate
+
-
+
-
HTTP 400 (Bad Request)
+
-
Cache-Control: no-cache
+
-
Connection: close
+
-
Date: Wed, 07 Apr 2010 08:48:00 GMT
+
-
Pragma: no-cache
+
-
Server: POE HTTPD Component/0.09 (5.008008)
+
-
Content-Length: 155
+
-
Content-Type: text/xml; charset=utf-8
+
-
Expires: Mon, 26 Jul 2010 17:32:09 GMT
+
-
+
-
<?xml version="1.0" encoding="UTF-8" ?>
+
-
<result>
+
-
<input_error>
+
-
<name>profile_id</name>
+
-
<error>RATING_TIMEOUT</error>
+
-
</input_error>
+
-
</result>
+
-
 
+
-
Rating in wrong phase:
+
-
 
+
-
$ curl -i -X POST -H "Accept: text/xml" \
+
-
-dprofile=http://127.0.0.1:10001/v1/solution/contestv2v2/profile/1.5J4L55FNLN2CZZDV \
+
-
-drating=1 \
+
-
http://127.0.0.1:10001/v1/solution/contestv2/contest/entry/1/rate
+
-
+
-
HTTP 400 (Bad Request)
+
-
Cache-Control: no-cache
+
-
Connection: close
+
-
Date: Thu, 25 Mar 2010 04:00:00 GMT
+
-
Pragma: no-cache
+
-
Server: POE HTTPD Component/0.09 (5.008008)
+
-
Content-Length: 108
+
-
Content-Type: text/xml; charset=utf-8
+
-
Expires: Mon, 26 Jul 2010 17:47:23 GMT
+
-
+
-
<?xml version="1.0" encoding="UTF-8" ?>
+
-
<result>
+
-
<terminal_error>OUT_OF_PHASE</terminal_error>
+
-
</result>
+
-
 
+
-
Rating non-existent entry:
+
-
 
+
-
$ curl -i -X POST -H "Accept: text/xml" \
+
-
-dprofile=http://127.0.0.1:10001/v1/solution/contestv2v2/profile/1.5J4L55FNLN2CZZDV \
+
-
-drating=1 \
+
-
http://127.0.0.1:10001/v1/solution/contestv2/contest/entry/5/rate
+
-
+
-
HTTP 404 (Not Found)
+
-
Cache-Control: no-cache
+
-
Connection: close
+
-
Date: Thu, 01 Apr 2010 04:00:00 GMT
+
-
Pragma: no-cache
+
-
Server: POE HTTPD Component/0.09 (5.008008)
+
-
Content-Length: 81
+
-
Content-Type: text/xml; charset=utf-8
+
-
Expires: Mon, 26 Jul 2010 17:48:16 GMT
+
-
+
-
<?xml version="1.0" encoding="UTF-8" ?>
+
-
<result>
+
-
<status>0</status>
+
-
</result>
+
-
 
+
-
Tattle on an entry:
+
-
 
+
-
$ curl -i -X POST -H "Accept: text/xml" \
+
-
-dprofile=http://127.0.0.1:10001/v1/solution/contestv2v2/profile/1.5J4L55FNLN2CZZDV \
+
-
-dreason='not work safe' \
+
-
http://127.0.0.1:10001/v1/solution/contestv2/contest/entry/1/tattle
+
-
+
-
HTTP 200 (OK)
+
-
Cache-Control: no-cache
+
-
Connection: close
+
-
Date: Thu, 01 Apr 2010 04:00:00 GMT
+
-
Pragma: no-cache
+
-
Server: POE HTTPD Component/0.09 (5.008008)
+
-
Content-Length: 502
+
-
Content-Type: text/xml; charset=utf-8
+
-
Expires: Mon, 26 Jul 2010 18:18:57 GMT
+
-
+
-
<?xml version="1.0" encoding="UTF-8" ?>
+
-
<result>
+
-
<entry>
+
-
<body>this is the body of my essay</body>
+
-
<category></category>
+
-
<city></city>
+
-
<description></description>
+
-
<entry_id></entry_id>
+
-
<entry_state>MI</entry_state>
+
-
<first_name></first_name>
+
-
<last_name></last_name>
+
-
<rating_ave>0.857</rating_ave>
+
-
<rating_count>7</rating_count>
+
-
<state></state>
+
-
<title>this is the title of my essay</title>
+
-
<views>0</views>
+
-
<votes>0</votes>
+
-
</entry>
+
-
</result>
+
-
 
+
-
Voting during wrong phase:
+
-
 
+
-
$ curl -i -X POST -H "Accept: text/xml" \
+
-
-dprofile=1.5J4L55FNLN2CZZDV \
+
-
http://127.0.0.1:10001/v1/solution/contestv2/contest/entry/1/vote
+
-
+
-
HTTP 400 (Bad Request)
+
-
Cache-Control: no-cache
+
-
Connection: close
+
-
Date: Thu, 01 Apr 2010 04:00:00 GMT
+
-
Pragma: no-cache
+
-
Server: POE HTTPD Component/0.09 (5.008008)
+
-
Content-Length: 108
+
-
Content-Type: text/xml; charset=utf-8
+
-
Expires: Mon, 26 Jul 2010 18:23:04 GMT
+
-
+
-
<?xml version="1.0" encoding="UTF-8" ?>
+
-
<result>
+
-
<terminal_error>OUT_OF_PHASE</terminal_error>
+
-
</result>
+
-
 
+
-
Voting timeout:
+
-
 
+
-
$ curl -i -X POST -H "Accept: text/xml" \
+
-
-dprofile=1.5J4L55FNLN2CZZDV \
+
-
http://127.0.0.1:10001/v1/solution/contestv2/contest/entry/1/vote
+
-
+
-
HTTP 400 (Bad Request)
+
-
Cache-Control: no-cache
+
-
Connection: close
+
-
Date: Tue, 20 Jul 2010 12:38:00 GMT
+
-
Pragma: no-cache
+
-
Server: POE HTTPD Component/0.09 (5.008008)
+
-
Content-Length: 155
+
-
Content-Type: text/xml; charset=utf-8
+
-
Expires: Mon, 26 Jul 2010 18:25:24 GMT
+
-
+
-
<?xml version="1.0" encoding="UTF-8" ?>
+
-
<result>
+
-
<input_error>
+
-
<name>profile_id</name>
+
-
<error>VOTING_TIMEOUT</error>
+
-
</input_error>
+
-
</result>
+
-
 
+
-
Successful vote:
+
-
 
+
-
$ curl -i -X POST -H "Accept: text/xml" \
+
-
-dprofile=1.5J4L55FNLN2CZZDV \
+
-
http://127.0.0.1:10001/v1/solution/contestv2/contest/entry/1/vote
+
-
+
-
HTTP 200 (OK)
+
-
Cache-Control: no-cache
+
-
Connection: close
+
-
Date: Sat, 10 Jul 2010 10:49:00 GMT
+
-
Pragma: no-cache
+
-
Server: POE HTTPD Component/0.09 (5.008008)
+
-
Content-Length: 502
+
-
Content-Type: text/xml; charset=utf-8
+
-
Expires: Mon, 26 Jul 2010 18:27:03 GMT
+
-
+
-
<?xml version="1.0" encoding="UTF-8" ?>
+
-
<result>
+
-
<entry>
+
-
<body>this is the body of my essay</body>
+
-
<category></category>
+
-
<city></city>
+
-
<description></description>
+
-
<entry_id></entry_id>
+
-
<entry_state>MI</entry_state>
+
-
<first_name></first_name>
+
-
<last_name></last_name>
+
-
<rating_ave>0.857</rating_ave>
+
-
<rating_count>7</rating_count>
+
-
<state></state>
+
-
<title>this is the title of my essay</title>
+
-
<views>0</views>
+
-
<votes>1</votes>
+
-
</entry>
+
-
</result>
+

Current revision

API Home Page :: Contest

Summary

Create a contest entry associated with this profile, specifying basic entry metadata such as a description and category. The API key will be preconfigured to expect a certain type of entry type (essay content, or binary image data). For binary image submissions, the form must be sent using Content-Type: multipart/form-data

Resource

/v1/{apikey}/contest/entry

Valid Methods

POST

Resource Arguments

Note: resource arguments are always required.

apikey: Your API Key.

Parameters Required

body: for an essay, this is the content of the entry

photo: photo URL retrieved from Photo Upload Key

title: entry title

category: category to be entered into

description: description of entry (usually has a character or word length associated)

original_work: send 'yes' after the user has agreed this is his own work

official_rules: send 'yes' after the user agrees his entry conforms to the rules of the contest.

Note: other fields may be required depending on the configuration of your API Key



Example: Submitting a blank entry

Summary

Demonstrates validation errors on missing parameters

Request

profile: http://{client}.api.promo.eprize.com/v1/{apikey}/profile/{uid}.{webkey}

Response

HTTP Status Code: 400 Bad Request


<?xml version="1.0" encoding="UTF-8" ?>
 <result>
   <input_error>
     <name>body</name>
     <error>NULL</error>
   </input_error>
   <input_error>
     <name>title</name>
     <error>NULL</error>
   </input_error>
   <input_error>
     <name>category</name>
     <error>NULL</error>
   </input_error>
   <input_error>
     <name>original_work</name>
     <error>NULL</error>
   </input_error>
   <input_error>
     <name>official_rules</name>
     <error>NULL</error>
   </input_error>
 </result>

Notes

The {profile} value that is seen in the request of this call is the canonical URL of the profile that the entry is associated with.

Example: Submitting a entry successfully

Request

profile: http://{client}.api.promo.eprize.com/v1/{apikey}/profile/{uid}.{webkey}
body: "this is the body of my essay"
title: "this is the title of my essay"
original_work: yes
official_rules: yes
category: 1

Response

HTTP Status Code: 201 Created

HTTP Redirect Location: /v1/{apikey}/contest/entry/{entryid}

<?xml version="1.0" encoding="UTF-8" ?>
 <result>
   <entry>
     <body>this is the body of my essay</body>
     <category>1</category>
     <city>PLEASANT RIDGE</city>
     <description></description>
     <entry_id>1</entry_id>
     <entry_state>transmuted</entry_state>
     <first_name>Todd</first_name>
     <last_name>C</last_name>
     <rating_ave>0.000</rating_ave>
     <rating_count>0</rating_count>
     <state>MI</state>
     <title>this is the title of my essay</title>
     <views>0</views>
     <votes>0</votes>
   </entry>
 </result>

Notes

The {profile} value that is seen in the request of this call is the canonical URL of the profile that the entry is associated with.

Personal tools