Examples of requests#

STANDARD PRO

The page contains the examples of cURL command using the PFLB Platform RESTful API:

Examples are given for Linux and MacOSX. If you are using Windows, please note that the syntax depends on the version of the cURL utility and the command shell you are using. For example, you need to change the followings if you are using the cURL built into Windows 10 and the cmd.exe command line:

  • Replace \ with ^ for a line break.

  • Replace all single quotes '' with double quotes "".

  • If the request body includes "", escape the double quotation with \.

Test runs#

Run a test#

To run a test, run the command:

curl --location --request POST 'https://platform.pflb.us/public-api/v1/testRun' \
--header 'api-token: <Your API token>' \
--header 'Content-Type: application/json' \
--data '{
  "testId": 3,
  "testVersionId": 3,
  "testMode": "TEST",
  "inheritLabelsFromTest": true
}'

Header parameter:

Request body:

  • testId. The unique identifier for the test. To find the ID, follow these steps:

    1. Go to the Tests page.

    2. Select the test. The test ID is displayed in the address bar: testId

  • testVersionId. The unique identifier for the test version. If the parameter isn’t specified, a the latest test’s version will run. To find the version ID, follow these steps:

    1. Go to the Test run page.

    2. Select the test run.

    3. Click Test. The ID of the test’s version is displayed in the address bar: testVersionId

  • testMode. Test run mode. Possible values

    • TEST. The usual test.

    • DEBUG_TEST. Debug test.

  • inheritLabelsFromTest. If true, labels are copied from a test to a test run.

See also

Get SLA results#

To get SLA results, run the command:

curl --location --request GET 'https://platform.pflb.us/public-api/v1/testRun/sla?testRunId=304' \
--header 'api-token: <Your API token>'

Query parameter:

  • testRunId. The unique identifier for the test run. To find the test run ID, use one of the following methods:

    • Send the request for running a test. The ID is included in the response in the id property.

    • Find it in the address bar:

      1. Go to the Test run page.

      2. Select the test run. The test run ID is displayed in the address bar: testRunId

Header parameter:

Tests and versions#

Create test versions#

To create a test version with new parameters, run the command:

curl --request POST \
--url https://platform.pflb.us/public-api/v1/testVersion \
--header 'Content-Type: application/json' \
--header 'api-token: <Ваш API токен>' \
--data '{
  "id": 3,
  "versionId": 47,
  "updateFileList": [
    {
      "filename": "login.csv",
      "newFileName": "login_v2.csv",
      "location": "teams/3/uploaded_files/file_4f132253-b2c2-4c9a-b5f3-816d637cb57.csv"
    }
   ],
   "variableList": [
    {
      "name": "host",
      "value": "https://ecommerce.pflb.us/",
      "description": "string"
    }
   ],
   "comment": "string"
   }'

Header parameter:

Request body:

  • id. The unique identifier for the test.

  • versionId. The unique identifier for the test version. If the parameter isn’t specified, a the latest test’s version will run. To find the version, follow these steps:

  • updateFileList.filename. The name of the previous CSV file.

  • updateFileList.newFileName. The name of the new CSV file.

  • updateFileList.location. The path to the CSV file in the platform storage. Insert the value of the location property from the response to load the CSV file.

  • variableList.name. The parameter name. It must match the name of the parameter in the test.

  • variableList.value. The new parameter value.

  • variableList.description. The parameter description.

  • comment. Comments for the test version.

Create a test based on a JMeter script#

To create a test based on the JMeter script, run the command:

curl --request POST \
--url 'https://platform.pflb.us/public-api/v1/test/jmx?testName=JMX-test&comment=Add%20timer' \
--header 'Content-Type: multipart/form-data' \
--header 'api-token: <Ваш API токен>' \
--form 'jmx=@/home/csv/csv.jmx' \
--form 'file=@/home/csv/params.csv'

Query parameter:

  • testName. The name of the new test.

  • comment. Comments for the test version.

Header parameter:

Request body:

  • jmx. The path to the JMX file.

  • file. The path to the supporting files that the script uses.

Get a list of tests for the team#

To get a list of tests for the team, run the command:

curl --request GET \
--url 'https://platform.pflb.us/public-api/v1/test?page=0&size=2&sort=name%2Cdesc' \
--header 'api-token: <Your API token>'

Query parameter:

  • page. The starting page number. Minimum value is 0.

  • size. The page size is the number of tests on a single page. Possible values are from 1 to 10.

  • sort. The sort settings define:

    • The field by which items are sorted. Possible field values are id, name, lastModified, labelSet.

    • The sorting direction. Possible values: asc is sort in ascending order, desc is sort in descending order. To specify the direction, add a comma %2C and asc or desc to the field name.

Header parameter:

Files and settings#

Update a CSV parameter in the settings set#

To update the CSV parameter in the settings set, follow these steps:

  1. Upload the CSV file to the storage:

    curl --request POST \
    --url https://platform.pflb.us/public-api/v1/file \
    --header 'Content-Type: multipart/form-data' \
    --header 'api-token: <Ваш API токен>' \
    --form 'files=@/home/csv/params.csv'
    

    Header parameter:

    Body request parameter:

    • files. Path to the CSV file.

  2. From the response, copy the value of the location property. It’s the path to the CSV file in the platform storage.

    Example of the response:

    [
      {
        "originalFileName": "params.csv",
        "location": "teams/3/uploaded_files/file_4f132253-b2c2-4c9a-b5f3-816d637cb57d.csv"
      }
    ]
    
  3. Update the CSV parameter in the settings set. Use the copied value of the location property in the response:

    curl --request PUT \
    --url https://platform.pflb.us/public-api/v1/testSetting \
    --header 'Content-Type: application/json' \
    --header 'api-token: <Your API token>' \
    --data '{
       "settingsId": 2,
       "updateFileList": [
          {
             "filename": "login.csv",
             "newFileName": "login_v2.csv",
             "location": "teams/3/uploaded_files/file_4f132253-b2c2-4c9a-b5f3-816d637cb57.csv"
          }
          ],
       }'
    

    Header parameter:

    Request body:

    • settingsId. The unique identifier for the settings set. To find the ID, follow these steps:

      1. Go to the Tests page and open the Settings tab.

      2. Open the settings set. The settings set ID is displayed in the address bar: settingsId

    • updateFileList.filename. The name of the previous CSV file.

    • updateFileList.newFileName. The name of the new CSV file.

    • updateFileList.location. Path to the CSV file in the platform storage. Insert the value of the location property from the response to load the CSV file.

See also

Update a literal parameter in the settings set#

To update the literal parameter in the settings set, run the command:

curl --request PUT \
   --url https://platform.pflb.us/public-api/v1/testSetting \
   --header 'Content-Type: application/json' \
   --header 'api-token: <Ваш API токен>' \
   --data '{
      "settingsId": 2,
      "variableList": [
         {
            "name": "host",
            "value": "https://ecommerce.pflb.us/",
            "description": "string"
         }
         ]
      }'

Header parameter:

Request body:

  • settingsId. The unique identifier for the settings set. To find the ID, follow these steps:

    1. Go to the Tests page and open the Settings tab.

    2. Open the settings set. The settings set ID is displayed in the address bar: settingsId

  • variableList.name. The parameter name. It must match the name of the parameter in the settings set.”

  • variableList.value. The new parameter value.

  • variableList.description. The parameter description.

See also

Update supporting files for JMX test#

To update supporting files for the tests based on the JMeter script:

  1. Upload the file to the storage:

    curl --request POST \
    --url https://platform.pflb.us/public-api/v1/file \
    --header 'Content-Type: multipart/form-data' \
    --header 'api-token: <Ваш API токен>' \
    --form 'files=@/home/test/data.txt'
    

    Header parameter:

    Body request parameter:

    • files. Path to the file.

  2. From the response, copy the value of the location property. It’s the path to the file in the platform storage.

    Example of the response:

    [
      {
        "originalFileName": "data.txt",
        "location": "teams/3/uploaded_files/file_4f132253-b2c2-4c9a-b5f3-816d637cb57d.txt"
      }
    ]
    
  3. Create a JMX test version with the new supporting files:

    curl --request POST \
    --url https://platform.pflb.us/public-api/v1/testVersion \
    --header 'Content-Type: application/json' \
    --header 'api-token: <Ваш API токен>' \
    --data '{
      "id": 3,
      "versionId": 47,
      "updateFileList": [
        {
          "filename": "data.txt",
          "newFileName": "data_v2.txt",
          "location": "teams/3/uploaded_files/file_4f132253-b2c2-4c9a-b5f3-816d637cb57.txt"
        }
       ],
       "comment": "string"
       }'
    

    Header parameter:

    Request body:

    • id. The unique identifier for the test.

    • versionId. The unique identifier for the test version. If the parameter isn’t specified, a the latest test’s version will run. To find the version, follow these steps:

    • updateFileList.filename. The name of the previous supporting file.

    • updateFileList.newFileName. The name of the new supporting file.

    • updateFileList.location. The path to the file in the platform storage. Insert the value of the location property from the response to load the file.

    • comment. Comments for the test version.

See also