User Quiz Submit


Request Details

Item Value
Description This endpoint submits user's poll response.
Method POST
Endpoint https://[environment]api[client_id].crowdtwist.com/v2/users/[user_id]/quiz/[activity_id]/response
HTTP Header X-CT-Authorization = CTApiKey [API Key]
Note: There is a space between CTApiKey and the API Key value.
Content Type application/json

Request

Field Name Sample Value Required Type Description
URL PARAMETERS
user_id 4532 Yes Integer The ID of the user submitting the poll.
activity_id

1

Yes Integer The ID of the poll.
QUERY PARAMETERS
api_key QWERTYP Yes String  
id_type

email

No String Type of ID being sent, defaults to ID if not specified. Options:
– email
– facebook_user_id
– twitter_user_id
– id (CrowdTwist ID default if blank)
– third_party_id
– username
– mobile_phone_number


Request Body

Field Name Sample Value Required Format Description
quiz_response See the QUIZ RESPONSE ARRAY section. Yes Array An array of quiz responses.
QUIZ RESPONSE ARRAY
question_id 1 Yes Integer The id of the question.
selected_answers [1,2,3] Yes Array An array of select answer options.

Response

Response Body

Field Name

Sample Value

Required

Format

Description

activity_id 1 Yes Integer The id of the poll.
message "quiz response submitted successfully" Yes String A response message.
score 2 Yes Integer The number of questions a member answered correctly.
points_awarded 100 Yes Integer The number of points this user was awarded.
total_responses 9627 Yes Integer The total number of responses to this quiz.
quiz_response See the QUIZ RESPONSE ARRAY section. Yes Array An array of quiz responses.
QUIZ RESPONSE ARRAY
question_id 1 Yes Integer The id of the question.
selected_answers [1,2,3] Yes Array An array of select answer options.
correct_answers [1,2,3] Yes Array An array of correct answer options.



Error Responses

Field Name

Sample Value

Required

Format

Description

error

Field value is empty.

Yes

String

This is a short form of the error.

message

Value of field [fieldname] must not be empty

Yes

String

This is a detailed message around the error specifying, as specifically as possible, what the fields are that are missing or where exactly the error is.


Error Response Codes

Error Error Code Description Reason
Input Error 4xx Returned whenever the request is missing required fields, including situations in which the body is malformed (e.g. HTTP method not supported, receipt not found, etc.). – missing_data
– not_unique
– receipt_not_found
– invalid_amount
– invalid_currency
– invalid_date
– invalid_custom_field
– invalid
Server Error 5xx HTTP error status code is returned due to an error that occurred in the backend. – internal_error: unexpected error occurred in the CrowdTwist backend
– missing_field
– invalid_data
– not_configured: error occurs when an configuration has not been configured yet


Example Response Codes

Response Code Error Message
400 input_error Member has already submitted a response.
403 forbidden Survey is not active.
404 page_not_found Unable to find user.

Samples

Sample Request

curl -X POST 'https://api.crowdtwist.com/v2.1/users/test@crowdtwist.com/survey/123/response?api_key=QWERTYUIOP&id_type=email'

 

Sample Request Body

{ "survey_response":[ { "question_id": 1, "selected_answers": null, "text_answer": "My survey question answer", "other": null }, { "question_id": 2, "selected_answers": [1], "text_answer": null, "other": null }, { "question_id": 3, "selected_answers": [1, 2, 3], "text_answer": null, "other": "free form response for other option" } ] }

 

Sample Response Body

{ "activity_id": 1, "message": "survey response submitted successfully", "points_awarded": 100, "total_responses": 500000 }

 

Sample Error Response

{ "error": "input_error", "message": "Member has already submitted a response." }