(Quick Reference)

66 Questions - Reference Documentation

Version: 2.1

66 Questions

66.1 List

Service: List of questions

Description: This web service returns a JSON list of questions.

URL:

https://BASE_URL/api/VERSION/questions

Method: GET

Parameters:

Pagination parameters:

NameDescriptionTypeRequiredPossible values
maxLimits the number of resources requested to return.Integerno 
offsetTells where to start returning records from the entire set of results.Integerno 
orderOrders ascending or descending.Integernoasc,desc
sortOrders the results by the specified field.Stringno 

The max parameter is set to 100 by default.

Filters parameters:

NameDescriptionTypeRequiredExample values
dateCreated_gtFilters by the resource's creation date time and operator greater thanDateno2016-08-15T14:52:48Z
dateCreated_gteFilters by the resource's creation date time and operator greater than or equalDateno 
dateCreated_ltFilters by the resource's creation date time and operator less thanDateno 
dateCreated_lteFilters by the resource's creation date time and operator less than or equalDateno 
lastUpdated_gtFilters by the resource's last-modified date time and operator greater thanDateno 
lastUpdated_gteFilters by the resource's last-modified date time and operator greater than or equalDateno 
lastUpdated_ltFilters by the resource's last-modified date time and operator less thanDateno 
lastUpdated_lteFilters by the resource's last-modified date time and operator less than or equalDateno 
surveyNameWildcard search by the survey's nameStringnosurveyName=*Quality of product*
typeSearch by the resource's typeIntegerno1, 2, 3

Dates should be formatted as the ISO-8601 format (YYYY-MM-DDTHH:MM:SSZ)

Success Output

Success case: response.status = 200

{
  "paging": {
    "total": 1,
    "max": 100,
    "offset": 0,
    "previous": null,
    "next": null
  },
  "data": [
    {
      "id": 7,
      "survey": {
        "id": 4,
        "name": "Quality and satisfaction with documentation",
        "href": "/api/v1.0/surveys/4"
      },
      "text": "How satisfied are you with the appropriateness of the documentation to your needs?",
      "type": "2",
      "isMandatory": true,
      "isPhotoMandatory": false,
      "enabled": true,
      "questionOptions": [
        {
		  "id": 10,
		  "text": "Satisfied",
		  "href": "/api/v1.0/questionOptions/10"
		},
		{
		  "id": 11,
		  "text": "Dissatisfied",
		  "href": "/api/v1.0/questionOptions/11"
		},
		{
		  "id": 12,
		  "text": "Neutral",
		  "href": "/api/v1.0/questionOptions/12"
		}
      ],
      "answers": [],
      "questionLines": null,
      "questionColumns": null,
      "dynamicLines": false,
  	  "addFilterByCategory": false,
      "organization": "entity1",
      "dateCreated": "2016-08-29T10:01:57Z",
      "lastUpdated": "2016-08-29T10:20:10Z"
    }
  ]
}

Failure Output

Failure case:response.status = 400

{
  "error": "invalid_param",
  "error_description": "The parameters [dateCreated_gta] you provided are not valid for this request."
}
{
    "error": "invalid_datetime_format",
    "error_description": "Invalid datetime filter (not ISO-8601 formatted): [2016/08/29]"
}

Failure case:response.status = 500
{
    "error": "server_error",
    "error_description": "Oops! Something went wrong..."
}

66.2 Show

Service: Show a question

Description: This web service return an existing question of the specified id in JSON format

URL:

https://BASE_URL/api/VERSION/questions/{id}

Method: GET

Parameters:

NameDescriptionTypeRequiredExample values
idThe numerical ID of the desired questionLongYes777

Success Output

Success case: response.status = 200

{
  "id": 7,
  "survey": {
    "id": 4,
    "name": "Quality and satisfaction with documentation",
    "href": "/api/v1.0/surveys/4"
  },
  "text": "How satisfied are you with the appropriateness of the documentation to your needs?",
  "type": "2",
  "isMandatory": true,
  "isPhotoMandatory": false,
  "enabled": true,
  "questionOptions": [
    {
      "id": 10,
      "text": "Satisfied",
      "href": "/api/v1.0/questionOptions/10"
    },
    {
      "id": 11,
      "text": "Dissatisfied",
      "href": "/api/v1.0/questionOptions/11"
    },
    {
      "id": 12,
      "text": "Neutral",
      "href": "/api/v1.0/questionOptions/12"
    }
  ],
  "answers": [],
  "questionLines": null,
  "questionColumns": null,
  "dynamicLines": false,
  "addFilterByCategory": false,
  "organization": "entity1",
  "dateCreated": "2016-08-29T10:01:57Z",
  "lastUpdated": "2016-08-29T10:20:10Z"
}

Failure Output

Failure case: response.status = 400
{
    "error": "invalid_param_type",
    "error_description": "The type of parameter id you provided is not valid for this request."
}

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

66.3 Create

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."
}

66.4 Update

Service: Update a question

Description: Returns the updated question in JSON format when successful.

URL:

https://BASE_URL/api/VERSION/questions/{id}

Method: PUT

Request content type: application/json

Parameters:

NameDescriptionTypeRequiredExample values
idThe numerical ID of the desired questionIntegeryes123
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

Success Output

Success case: response.status = 200

{
  "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": "invalid_param_type",
  "error_description": "The type of parameter surveyId you provided is not valid for this request."
}
{
  "error": "invalid_param_type",
  "error_description": "An invalid value was specified for parameter: isPhotoMandatory (must be Boolean)"
}
{
  "error": "missing_param",
  "error_description": "questionOptions parameter is missing"
}
{
  "error": "update_not_authorized",
  "error_description": "Question with answers could not be updated"
}
{
  "error": "update_not_authorized",
  "error_description": "Survey with id 4 has already answers"
}

Failure case: response.status = 404

{
  "error": "not_found",
  "error_description": "The survey with the id 44 doesn't exist."
}

66.5 Delete

Service: Delete a question

Description: Returns a JSON response.

URL:

https://BASE_URL/api/VERSION/questions/{id}

Method: DELETE

Parameters:

NameDescriptionTypeRequiredExample values
idThe numerical ID of the desired questionIntegeryes123

Success Output

Success case: response.status = 200

{
  "success": "true",
  "success_description": "Instance deleted successfully"
}

Failure Output

Failure case: response.status = 400

{
  "error": "delete_failed",
  "error_description": "Failed to delete instance."
}
{
  "error": "delete_not_authorized",
  "error_description": "Question with answers could not be deleted"
}
Failure case: response.status = 404

{
  "error": "not_found",
  "error_description": "The question with the id 123 doesn't exist."
}