Link Search Menu Expand Document

API Response

Every API Request needs to have at least one Response, which is automatically executed at the end of the Request. Only one Response is called for every API Request execution based on the HTTP status code the server returns. There are also the special Offline and Timeout responses that are not based on the status code.

Status Code

You can either type the exact status code (for example 200), or one of the special values.
Note: You cannot have multiple responses with the same status code.

Number from 200 to 500

If you type the status code that you expect the server to return, then the Response will be called only if this exact status code is returned.

General 4xx error

If you type 4xx as the status code, this Response will be used as a catch-all response for status codes from 400 to 499.

General 5xx error

if you type 5xx as the status code, this Response will be used as a catch-all response for status codes from 500 to 599.

Catch All xxx

If you type xxx as the status code, then this Response will be used as a catch-all response for any status code that is not handled by any other Response.
Note: If you have a 4xx and/or 5xx response, these will be used and not the xxx for the 400-499 and/or 500-599 status codes.
Tip: It is not required to add a catch all Response, but it is a good practice to show an error when the server returns something unexpected.

Offline

If you type offline as the status code, this Response will be executed when the user has no Internet connection or if the Internet connection is lost during the Request.

Timeout

If you type timeout as the status code, this Response will be executed if the server has not returned a response after the defined timeout interval.

Function Name

The name of the Function that will be called if the API Request is executed using a Code Block. It is also the response name if the API Request is used in a Datasource.
Note: This value is not visible to the users.

Response Parameters

Each Response can have one or more response parameters populated with the JSON response data. Response parameters Data types can either use a JSON supported Data Type or a Model.
Tip: You may also need to set the Parameter Path to define the position of the value in the JSON.

Parameter Name

The name of the parameter in Datasource or Code Blocks to use when you set up the API Request execution.
Note: This value is not visible to the users and has no connection with the JSON keys.

Parameter Type

Response parameters Data types can either use a JSON supported Data Type or a Model and should match the Data Type of the value in the JSON.

Parameter Path

The path in the JSON where the parameter value is. You can access nested JSON paths by using the dot ..
Note: If you don’t use a Model, for example, to get only a Text value, you will also need to use the Parameter path to define the JSON key. For Models, the parameter path is optional. Kodika will automatically assign the JSON keys to the Model properties.

Example:

{
  "id": 1,
  "name": "Leanne Graham",
  "username": "Bret",
  "isActive": true,
  "address": {
    "street": "Kulas Light",
    "suite": "Apt. 556",
    "zipcode": "92998-3874",
    "geo": {
      "lat": -37.3159,
      "lng": 99.1496
    }
  }
}
With Suggested Data Types
Path Data Type Value
id Int 1
name Text Leanne Graham
isActive Bool true
address.street Text Kulas Light
address.geo.lat Number -37.3159
With Model Data types

You can create two Models, Person and Address. Each Model property should have the name and Data Type matching the ones in the JSON. Person can also have an address property, with Address Data Type. To use these, you can:

  • Set an empty path and assign the Person Data Type.
  • Set the address path and assign the Address Data Type.

Note: Parameter path will not work for array JSON values.