User Survey Update


Request Details

Item Value
Description Updates a survey response.
Method PUT
Endpoint https://api.crowdtwist.com/v2/survey/[survey_id]/?api_key=[api_key]&id_type=[id_type]
Content Type: JSON (application/json)


Request

Field Name Sample Value Required Format Notes
URL PARAMETERS
survey_id 23 Yes String ID of survey being updated
QUERY STRING PARAMETERS
api_key QWERTYUIOP 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
user_id 1 Yes Mixed ID of user.
survey_responses Response Object Yes Array Array of answers to survey questions.
RESPONSE OBJECT
id 45 No String ID of question.
value Drug Store No String Answer to question specified in id field.


Successful Response

Field Name Sample Value Required Format Description
id 225 Yes String CrowdTwist internal ID for activity
date_created 1425404945 Yes Integer Date activity was recorded
name shared a link Yes String Name of activity
num_points 1000 Yes Integer Points earned for completing activity
extra_data {
survey_type : “monthly”
}
No JSON Extra data set via User Survey Submit API (JSON)

Successful Response – Request Body

Field Name Sample Value Required Format Description
id 45 No String ID of question.
value Drug Store No String Answer to question specified in id field


Error Response

Field Name Sample Value Required Format Description
error param_error Yes String A machine readable code that describes the error.
message Missing the user_id parameter Yes String A short, descriptive sentence detailing the error.


Error Response Codes

Error Message
input_error The input provided in invalid or formatted incorrectly.
internal_error Something went wrong on our end.
page_not_found The requested page does not exist or has been removed.
param_error A missing or invalid parameter is included in the request.
questions_required Answers to one or more questions required.


Sample Request

curl -X PUT
https://api.crowdtwist.com/v2/survey/23/?api_key=QWERTYUIOP&id_type=email
{
  "user_id": "13546",
  "survey_responses": [
    {
      "id": "45",
      "value": "Drug Store"
    },
    {
      "id": "56",
      "value": "Department Store"
    }
  ],
  "extra_data": {
    "survey_type": "monthly"
  }
}
curl -X PUT
https://api.crowdtwist.com/v2/survey/23/?api_key=QWERTYUIOP&id_type=email
{
  "user_id": "13546",
  "survey_responses": [
    {
      "id": "45",
      "value": "Drug Store"
    },
    {
      "id": "56",
      "value": "Department Store"
    }
  ],
  "extra_data": {
    "survey_type": "monthly"
  }
}


Sample Successful Response: Status Code 200

{
  "activity_id": 12345,
  "date_created": 143216432,
  "name": "survey activity name",
  "num_points": 100,
  "extra_data": {
    "survey_type": "monthly"
  }
}
{
  "activity_id": 12345,
  "date_created": 143216432,
  "name": "survey activity name",
  "num_points": 100,
  "extra_data": {
    "survey_type": "monthly"
  }
}

Sample Error Response: Status Code 400

{
  "error": "param_error",
  "message": "Missing the #user_id parameter."
}
{
	"error": "param_error",
	"message": "Missing the #user_id parameter."
}