(Quick Reference) Service: Create a question

Description: Returns the created question in json format when successful. Returns a json response, describing the failure condition when unsuccessful.

URL:

https://BASE_URL/api/VERSION/questions

Method: POST

Request content type: application/json

Parameters:

NameDescriptionTypeRequiredExample values
texttext of the questionStringyes 
typeShould be equal to 1 if multiple choice, 2 if unique choice, 3 if text, 4 if date, 5 if number, 6 if likert scale, 7 if table and 8 if drop down listIntegeryes1,2,3
surveyIdThe numerical ID of surveyIntegeryes 
enabledBy default, it is set to trueBooleannotrue, false
questionOptionsRequired if type is equal to 1, 2 or 8JSON list-"{'text' : 'option1' },{'text' : 'option2'}" , "{'text' : 'Go' , 'branch' : '1'},{'text':'STOP'}"
isMandatoryIndicate if the answer to the question is required or not, set to true by defaultBooleannotrue, false
isPhotoMandatoryIndicate if the answer to the question needed to be with photo or not, set to false by defaultBooleannotrue, false
linesRepresent the question lines for the question of type tableJSON listyes if type = 7"{'value' : '4'},{'value' : '6'}"
columnsRepresent the question columns for the question of type tableJSON listyes if type = 7"{'text' : 'How is the quality', 'type' : '1' , options : [{text : good},{text : bad }}]"
linesTypeIndicate the type of question lines . Should be equal to 1 if item, 2 if item category, 3 if item group, 4 if textIntegeryes if type = 71,2,3,4

Parameters: questionOptions

NameDescriptionTypeRequiredExample values
texttext describing the optionStringyes'good' , 'bad'
branchid of the question to be branched with the destined optionLongno77

the branch parameter is considered only for those two type of questions unique choice and the drop down list

Success Output

Success case: response.status = 201

{
  "id": 35,
  "survey": {
    "id": 10,
    "name": "Quality of products",
    "href": "/api/v1.0/surveys/10"
  },
  "text": "Table Question",
  "type": "7",
  "isMandatory": true,
  "isPhotoMandatory": false,
  "enabled": true,
  "questionOptions": [
    {
      "id": 59,
      "text": "Good",
      "href": "/api/v1.0/questionOptions/59"
    },
    {
      "id": 60,
      "text": "Acceptable",
      "href": "/api/v1.0/questionOptions/60"
    },
    {
      "id": 61,
      "text": "Bad",
      "href": "/api/v1.0/questionOptions/61"
    }
  ],
  "answers": [],
  "questionLines": [
    {
      "id": 1,
      "text": "Product Baby2",
      "href": "/api/v1.0/questionLines/1"
    }
  ],
  "questionColumns": [
    {
      "id": 1,
      "name": "How do you find our product ?",
      "href": "/api/v1.0/questionColumns/1"
    }
  ],
  "dynamicLines": false,
  "addFilterByCategory": false,
  "organization": "entity1",
  "dateCreated": "2016-11-25T09:11:47Z",
  "lastUpdated": "2016-11-25T09:11:47Z"
}

Failure Output

Failure case: response.status = 400
{
  "error": "save_not_authorized",
  "error_description": "Survey with id 4 has already answers"
}
{
  "error": "missing_param",
  "error_description": "questionOptions parameter is missing"
}
{
  "error": "invalid_param_type",
  "error_description": "An invalid value was specified for parameter: type (must be in list)"
}
{
  "error": "invalid_param_type",
  "error_description": "An invalid value was specified for parameter: isPhotoMandatory (must be Boolean)"
}

Failure case: response.status = 404
{
  "error": "not_found",
  "error_description": "The survey with the id 4 doesn't exist."
}