Send Docs Feedback

Note: Most user interface tasks can be performed in Edge Classic or the New Edge experience. For an overview, getting started topics, and release notes specific to the New Edge experience, see the docs.

Create a Test Case

Resource Summary

Security

Content Type

application/json

Category

Apigee Test,

CreateaTestCase

POST

Create a Test Case

In Apigee Test, a Test Case is a collection of API calls that are made in a specified order. Test Cases succeed or fail based on the response criteria you set. A Test Case can be executed automatically by being added to a Probe or manually with a webhook.

There are a lot of configuration possibilities for Test Cases, so before creating a Test Case with this API, you may want to create one in the UI to better understand the concepts.

 

Also, a good way to figure out how to create the Test Case you want with the API is to first create one in the UI, then run the List Test Cases API to get its ID, then run the Get a Test Case to see its structure. For more information on creating Test Cases with the UI, see Test Cases.

The sample JSON payload below creates a simple Test Case with two API calls (Steps). It includes:

  • JavaScript that sets a variable before each call.
  • A URL that references the JavaScript variable for the host portion of the URL.
  • Success criteria based on an HTTP response code of 2xx (any 200-level response).
  • An variable extracted from the response header. The variable could either be referenced in subsequent calls using ${variable_name}, or its value could be used to assert the response (determine whether the API call was a success or failure).

 

Resource URL

https://api.test.apigee.com/v1 /organizations/{org_name}/testcases

Header Parameters

Name Values Description
Content-Type
(required)

application/json

Request Body

In the payload, be sure to escape any quotation marks (\") that are to be used literally.

Property Description
statusCode Valid values: 2xx, 200, 201, 202, 3xx, 301, 302, 307, 4xx, 400, 401, 403, 404, 405, 415, 5xx, 500, 502, 503
extractVariables type

Valid values:res_header (Response Header) or jsonpath (Response Body (JSON))

If you want to extract a variable in a response payload for proxy chaining or asserting a response, you can get the variable from the response header or response body using JSONPath.

 "extractVariables": [
          {
            "type": "res_header",
            "name": "Custom name for the variable",
            "value": "Actual name of the header variable (if using the response header) or a JSONPath (if using the response body)."
           }
        ]
assertion variable types

ext_var (Extract Variable) or res_header (Response Header)

If you extracted a variable, you can use its value to assert the response (determine whether the call was a success or failure).

"variables": [
            {
              "name": "Name of the custom variable you created",
              "value": "Expected value for the call to be determined a success.",
              "type": "ext_var"
            }
          ]

HTTP Basic

OAuth 2.0

API Key

Reset

Make a request and see the response.

Make a request and see the response.

Make a request and see the response.

Response Error Details

  • HTTP Code
    Error Code
    Description
  • 400

    Bad Request

  • 401

    Unauthorized

  • 403

    Forbidden

  • 500

    Internal Server Error

Working...

Help or comments?