Create profile
From ePrize Developers Wiki
Line 23: | Line 23: | ||
|response=<?xml version="1.0" encoding="UTF-8" ?> | |response=<?xml version="1.0" encoding="UTF-8" ?> | ||
<result ver="ePrize Web Services 1.0"> | <result ver="ePrize Web Services 1.0"> | ||
- | < | + | <profile> |
- | + | <id>{uid}</id> | |
- | + | <email>some.email@address.com</email> | |
- | + | <safekey1>safekey1-value</safekey1> | |
- | + | <safekey2>safekey2-value</safekey2> | |
- | + | ... | |
- | + | <safekeyN>safekeyN-value</safekeyN> | |
- | + | </profile> | |
- | + | ||
- | + | ||
- | + | ||
</result> | </result> | ||
}} | }} | ||
Line 43: | Line 40: | ||
|response=<?xml version="1.0" encoding="UTF-8" ?> | |response=<?xml version="1.0" encoding="UTF-8" ?> | ||
<result ver="ePrize Web Services 1.0"> | <result ver="ePrize Web Services 1.0"> | ||
- | < | + | <terminal_error>duplicate_account</terminal_error> |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
</result> | </result> | ||
}} | }} | ||
Line 59: | Line 49: | ||
|response=<?xml version="1.0" encoding="UTF-8" ?> | |response=<?xml version="1.0" encoding="UTF-8" ?> | ||
<result ver="ePrize Web Services 1.0"> | <result ver="ePrize Web Services 1.0"> | ||
- | < | + | <input_error> |
- | < | + | <error>VALIDATION</error> |
- | + | <name>field1</name> | |
- | + | </input_error> | |
- | + | <input_error> | |
- | + | <name>field2</name> | |
- | + | <error>NULL</error> | |
- | + | </input_error> | |
- | + | ... | |
- | + | <input_error> | |
- | + | <name>fieldN</name> | |
- | + | <error>NULL</error> | |
- | + | </input_error> | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | </ | + | |
- | + | ||
</result> | </result> | ||
+ | }} | ||
+ | |||
+ | {{RESTfulExample | ||
+ | |title=Invalid Request - Errors in JSON Format | ||
+ | |responsecode=400 Bad Request | ||
+ | |response={ | ||
+ | "result" : { | ||
+ | "input_error" : [ | ||
+ | { | ||
+ | "error" : "NULL", | ||
+ | "name" : "field1" | ||
+ | }, | ||
+ | { | ||
+ | "name" : "field2" | ||
+ | "error" : "VALIDATION", | ||
+ | }, | ||
+ | ... | ||
+ | { | ||
+ | "error" : "NULL", | ||
+ | "name" : "fieldN" | ||
+ | }, | ||
+ | ] | ||
+ | } | ||
+ | } | ||
}} | }} |
Revision as of 23:09, 29 March 2009
Summary
Promotion is configured with one unique {profile-key} such as email, user_name, or mobile_phone. At a minimum, the profile must have a {profile-value} for this key and {profile-value} must be unique within the promotion.
Additional key:value pairs may be submitted. The {apikey} may enforce rules on these pairs such as required vs optional, size limits and validation. Common examples of other keys are address, birthdate and optin. The name of a key must begin with a letter and consist of only lowercase ASCII letters, numbers and underscores.
Typically the {apikey} will be configured to require a CAPTCHA challenge/response in the request headers of an untrusted create profile request. A failed CAPTCHA is the same as a failed validation, resulting in a response of 400 Bad Request.
This URL is an entry point. It may be easily attacked because valid URLs are easy to guess. CAPTCHA protects against automated attacks.
Example: Profile Created
Summary
This demonstrates a successful profile creation.
Request
Form Post Variables email:some.email@address.com key1:key1-value key2:key2-value ... keyN:keyN-value
Response
HTTP Status Code: 201 Created
HTTP Redirect Location: /v1/{apikey}/profile/{uid}
<?xml version="1.0" encoding="UTF-8" ?> <result ver="ePrize Web Services 1.0"> <profile> <id>{uid}</id> <email>some.email@address.com</email> <safekey1>safekey1-value</safekey1> <safekey2>safekey2-value</safekey2> ... <safekeyN>safekeyN-value</safekeyN> </profile> </result>
Example: Profile Already Exists
Summary
This demonstrates an attempted profile creation that got rejected because a profile with the unique id (email in most cases) already exists.
Response
HTTP Status Code: 409 Conflict
<?xml version="1.0" encoding="UTF-8" ?> <result ver="ePrize Web Services 1.0"> <terminal_error>duplicate_account</terminal_error> </result>
Example: Invalid Request - Errors
Response
HTTP Status Code: 400 Bad Request
<?xml version="1.0" encoding="UTF-8" ?> <result ver="ePrize Web Services 1.0"> <input_error> <error>VALIDATION</error> <name>field1</name> </input_error> <input_error> <name>field2</name> <error>NULL</error> </input_error> ... <input_error> <name>fieldN</name> <error>NULL</error> </input_error> </result>
Example: Invalid Request - Errors in JSON Format
Response
HTTP Status Code: 400 Bad Request
{ "result" : { "input_error" : [ { "error" : "NULL", "name" : "field1" }, { "name" : "field2" "error" : "VALIDATION", }, ... { "error" : "NULL", "name" : "fieldN" }, ] } }