Types, Examples, and Response

In the article below you will find important information about the usage of the Testinvite’s API for fetching test results according to ticket ids. We will firstly explain structure and types of the request body, and then show some examples of calls in Postman and in different programming languages. Lastly we will describe the structure of the response body.

If you want to try API requests immediately you can check the Postman collection we have created for you. Please click here to download the Postman collection.

Types

There are 4 required properties for fetching test results related with a ticket: "requester", "taskId", "kind", and "tickets". Requester is an object containing properties related with authentication. Mainly you should include your organization's id and organization's private key in "auth" property of requester. "taskId" is the id of the task whose results going to be fetched. "kind" is used to mention according to what you want to query test results. For now our system has a query for test test results only according to ticket id so, it should be "by-ticket". Lastly, "tickets" is an array of objects where each array takes one property: "ticketId". You can find ids of tickets in the response of the ticket creation.

You can find request body's types in chart below representing body in tree view.

  • Request body Type Information
    • taskId string, required Task id for result query
    • kind string, required Kind of the query
    • requester object, required Container of organization info
      • name string, required Organization name
      • auth object, required Container of authentication properties
        • organizationId string, required Organization id
        • privateKey string, required Organization's private key
    • tickets array, required Container of ticket ids
      • ticketId string, required Id of the ticket.

Examples

In the examples below, you can see 2 different fetch requests. The example on the left is created in POSTMAN, and the right one is created according to cURL. You can use these examples simply by using your organization's id, private key, and taskId. To fetch your candidates' test results you should employ ticket ids that you gor from ticket creation request's response.

Fetching Results

Code examples below contain only required properties and are created for one ticket. You can see one object with "ticketId" property in the "tickets" array.

Example body

{
 "requester": {
 "name": "Organization Name",
 "auth": {
   "organizationId": "zUH8oMYJ60As4HYP",
   "privateKey": "a8faef00-43c1-11ed-81bc-976010"
   }
  },
 "taskId": "tcxHArKva33C8VxCZcjy",
 "kind": "by-ticket",
 "tickets": [
   {
    "ticketId": "33C8VxCZcjytcxHAr"
   }
  ]
}
                    

cURL

curl --location --request POST 
'https://www.testinvite.com/api/v1/fatih/query-test-results' \
--header 'Content-Type: application/json' \
--data-raw '{
  "requester": {
    "name": "Organization Name",
    "auth": {
      "organizationId": "zUH8oMYJ60As4HYP48Zx",
      "privateKey": "76f75bd0-4315-11ed-98ad-1127beb80c0d"
       }
      },
    "taskId": "Qj33evNTg7IjLnao2Ux1",
    "kind": "by-ticket",
    "tickets": [
       {
        "ticketId": "0dxZm5WJ42cbxCP6DQbn"
       }
     ]
}'
          

Fetching Results for Multiple Tickets

Requests below have two ticket ids in the tickets array which means that response will include multiple results in its "payload" array.

Example body

{
 "requester": {
 "name": "Organization Name",
 "auth": {
   "organizationId": "zUH8oMYJ60As4HYP48Zx",
   "privateKey": "76f75bd0-4315-11ed-98ad-1127beb80c"
   }
  },
 "taskId": "Qj33evNTg7IjLnao2Ux1",
 "kind": "by-ticket",
 "tickets": [
   {
    "ticketId": "0dxZm5WJ42cbxCP6DQbn"
   },
   {
       "ticketId": "xCP6DQbn0dxZm5WJ42cb"
   }
  ]
}
          

cURL

curl --location --request POST 
'https://www.testinvite.com/api/v1/fatih/query-test-results' \
--header 'Content-Type: application/json' \
--data-raw '{
  "requester": {
    "name": "Organization Name",
    "auth": {
      "organizationId": "zUH8oMYJ60As4HYP48Zx",
      "privateKey": "76f75bd0-4315-11ed-98ad-1127beb80c0d"
       }
      },
    "taskId": "Qj33evNTg7IjLnao2Ux1",
    "kind": "by-ticket",
    "tickets": [
       {
        "ticketId": "0dxZm5WJ42cbxCP6DQbn"
       },
       {
           "ticketId": "ggHtHoz0LbATu5C2VGGn"
       }
     ]
}'
          

Response Body

Response body mainly consists of two parts: "kind" and "payload". Kind property takes value according to the response status. If there is no error it should be "zetok", if there is, it will be "zeterror". As it contains all data about test results, payload array is the essential part of the response body. It is an array consisted of object/s where all the test result data is restored. In every object you should see different properties such as "ticketId", "testReference", "meta", and "testInstanceId" etc. We will explain here only important properties for test scores and further api calls.

The most important properties in payload are: "result", "testInstanceId", and "ticket". Test instance id is a string that is going to be used in fetching monitoring assets of the exam. So, if you have opened monitoring options for the task you should save this id in order to make api call for fetching monitoring assets. Result is an object, consisting of properties containing result data of the exam. Essential properties of result object are: "dimensions", "stats", and "sections". Dimensions property is important if you have included dimensions in the system for questions. "stats" is an object where general results of the exam are included. You can find in it candidate's wrong and right answers, total point that could be gained from the exam etc. "point" and "totalPoint" show the candidate's points and total points that could be gained from the exam respectively. "sections" is an array of objects where section-based data of results is contained. The structure of each object in the array is similar to "result" object where in them only section-based data is restored.

Response body will be as the tree view below. Instead of giving all types in the body we will mention only important ones in test results.

  • Response body Type Information
    • kind string Kind of the response according status
    • payload array Container of response properties.
      • ticketId string Ticket id of result data
      • apiTaskTicketRequestId string Id of the request. You should save it.
      • external object Container of the external data
      • testReference object Container of data such as test id, test title.
      • meta object Container of data such as folder, group.
      • result object Container of test result data.
        • stats object Container of the general results data
        • dimensions object Container of the points according to dimensions
        • sections array Container of the section-based results
          • stats object Container of the section-based results data
          • dimensions object Container of the points according to dimensions

Response Example

You can see one response example below for fetching one ticket's results. After having this response, it is recommended that you should save "testInstanceId", "point" and "totalPoints" in the stats property of result object for further process.

Response for Fetching one Ticket's Results

{
    "kind": "zetok",
    "payload": [
        {
            "ticketId": "0dxZm5WJ42cbxCP6DQbn",
            "apiTaskTicketRequestId": "ryakw32wZAGcZdo14NCi",
            "external": {
                "id": null,
                "data": null
            },
            "testReference": {
                "kind": "testreference",
                "title": "API Test1",
                "organizationId": "zUH8oMYJ60As4HYP48Zx",
                "testId": "ocMYFZc41A5SLflug5GE"
            },
            "meta": {
                "folder": "general",
                "group": "general",
                "labels": [],
                "tagLines": [
                    "requester",
                    "requester_*/|-?*_Yusuf's Company"
                ],
                "tagMap": {
                    "requester": "Yusuf's Company"
                }
            },
            "result": {
                "sections": [
                    {
                        "sectionInstanceUUID": "bf8464a0-43c0-11",
                        "stats": {
                            "noOfMatchQuestion": 0,
                            "noOfAnswered": 5,
                            "noOf100": 5,
                            "noOfInvalid": 0,
                            "noOfMultipleChoiceQuestion": 5,
                            "noOfIneffective": 0,
                            "noOfEvaluated": 0,
                            "noOfPartial": 0,
                            "noOfEmpty": 0,
                            "noOfInputQuestion": 0,
                            "totalPoint": 5,
                            "noOfIgnored": 0,
                            "noOfNotAnswered": 0,
                            "noOfManual": 0,
                            "point": 5,
                            "noOf0": 0,
                            "noOfQuestions": 5,
                            "noOfMissingEvaluation": 0,
                            "noOfNegative": 0,
                            "negative": 0,
                            "noOfPointy": 5,
                            "noOfRequireEvaluation": 0
                        },
                        .
                        .
                        .

                        "sectionIndex": 0
                    }
                ],
                "dimensions": {},
                "stats": {
                    "noOfNegative": 0,
                    "totalPoint": 5,
                    "noOfNotAnswered": 0,
                    "noOf100": 5,
                    "noOfPointy": 5,
                    "noOfMultipleChoiceQuestion": 5,
                    "noOfEvaluated": 0,
                    "noOfAnswered": 5,
                    "noOfEmpty": 0,
                    "noOfMatchQuestion": 0,
                    "noOfIneffective": 0,
                    "noOfPartial": 0,
                    "point": 5,
                    "noOfManual": 0,
                    "noOf0": 0,
                    "noOfQuestions": 5,
                    "noOfIgnored": 0,
                    "noOfRequireEvaluation": 0,
                    "noOfMissingEvaluation": 0,
                    "noOfInputQuestion": 0,
                    "negative": 0,
                    "noOfInvalid": 0
                },
            },
            .
            .
            .
        },
    ]
}