API Requests - campsych/concerto-platform GitHub Wiki

By using Concerto Platform API you can perform CRUD (Create, Read, Update, Delete) operations on your data tables, or test runner operations (e.g. start test, submit test page). You need to have valid access token to be able to do API requests.
See Obtaining Client Access Token for how to obtain one.

In each API request you make you need to include your access token in request header:
Authorization: Bearer [your access token]
Where ‘Authorization’ is header key and ‘Bearer [your access token]’ is header value.

CRUD operations on data tables

Let’s imagine we have a table named responses with following structure:

  • id (bigint)
  • answer (text)
  • date (date)
  • correct (boolean)

Reading Collection

  • Request:
    GET /api/data/responses
  • Success Response:
    code: 200
    content type: application/json
    body: JSON array with whole collection

Reading Filtered Collection

You can apply any field based filter to your query. Using our demonstration table ‘responses’ you might want to read only correct responses with date starting from 2016-07-20. To do this, perform following request:

  • Request:
    GET /api/data/responses?correct=true&date>=2016-07-20
  • Success Response:
    code: 200
    content type: application/json
    body: JSON array with matching records

Allowed filter operators:

  • = : equal
  • != : not equal
  • >= : equal or greater
  • <= : equal or lesser

Filters must be entered as URL parameters after ? character in URL. Field name must always be on the left side, followed by operator, followed by value. Multiple filters can only be connected by AND logical operator represented in URL by & character.

Reading Specific Record

  • Request:
    GET /api/data/responses/[id]
  • Success Response:
    code: 200
    content type: application/json
    body: JSON array with single element: requested object

Inserting New Record

  • Request:
    POST/PUT /api/data/responses
    content type: application/json
    body: JSON object representing record to insert
  • Success Response:
    code: 200
    content type: application/json
    body: JSON array with single element: inserted object

Updating Existing Record

  • Request:
    POST/PUT /api/data/responses/[id]
    content type: application/json
    body: JSON object representing new field values of updated record
  • Success Response:
    code: 200
    content type: application/json
    body: JSON array with single element: updated record

Deleting Existing Record

  • Request:
    DELETE /api/data/responses/[id]
  • Success Response:
    code: 200

Test runner methods

By using test runner methods you can bypass Concerto Platform test front-end and still use Concerto back-end for test logic.

Start Test

Use to start a new test session.

  • Request:
    POST /api/runner/test/[test_slug]/session/start
    POST /api/runner/test_n/[test_name]/session/start
    content type: application/json
    body: JSON object representing parameters to pass to test
  • Success Response:
    code: 200
    content type: application/json
    body: JSON array with response
    {
       ...
       "data": {
          "templateParams": { ... },
          "hash": ...
       }
    }

    body content:
    • data.templateParams – (json object) will contain parameters passed to front-end
    • data.hash – (string) will contain session hash that will later be used for subsequent submit to this session

Submit

Use to submit page to already running test session.

  • Request:
    POST /api/runner/test/session/[hash]/submit
    content type: application/json
    body: JSON object representing parameters to pass to test
    {
       "values": {
          ...
       }
    }
  • Success Response:
    code: 200
    content type: application/json
    body: JSON array with response
    {
       ...
       "data": {
          "templateParams": { ... },
          "hash": ...
       }
    }

    body content:
    • data.templateParams – (json object) will contain parameters passed to front-end
    • data.hash – (string) will contain session hash that will later be used for subsequent submit to this session

Kill

Use to terminate running session and free its resources.

  • Request:
    POST /api/runner/test/session/[hash]/kill
  • Success Response:
    code: 200
    content type: application/json
    body: JSON array with response

Keep alive

Use to perform keep alive check-in.

  • Request:
    POST /api/runner/test/session/[hash]/keepalive
  • Success Response:
    code: 200
    content type: application/json
    body: JSON array with response
⚠️ **GitHub.com Fallback** ⚠️