Send a CoAP request

Relevant for: API testing only

This topic explains how to add and configure a step to your API test, which will send a CoAP request to the CoAP server, and check the server's response.

This task is part of Create an API test.

Add a Send CoAP Request step

From the Toolbox pane, select CoAP > Send CoAP Request and drag it to the test canvas.

Back to top

Set the server details and request type

Define the CoAP server's URL, the type of CoAP request that you want to send, and what response type to accept:

  1. In the Properties pane, open the Input/Checkpoints tab to edit the Input.

  2. Enter the URL for the CoAP server resource. The URL must begin with one of the following formats:

    coap://<hostaddress>.<port number>

    coaps://<hostaddress>.<port number>

  3. Select the CoAP Method to send. Possible values: GET, POST, PUT, DELETE.
  4. Optionally, in the Accept box, select the type of data the test should expect to receive from server. For example, application/xml or application/json.

Back to top

Configure communication properties for the request

Specify whether to use reliable messaging, set the timeout, and any proxy information needed to access the CoAP server.

  1. In the Properties pane, open the General tab .

  2. Optionally configure the step Name and the following properties:

    Message type. Indicates whether to use Confirmable or Non-confirmable messages. By default OpenText Functional Testing uses Confirmable messages.

    Timeout. In milliseconds (Default=2000)

Back to top

Create the body of the request

Provide the body content of the request that this step sends to the CoAP server:

  1. In the Properties pane, open the CoAP tab.

  2. Specify the type of data this request contains. Possible types: XML, Text, File, JSON.

    When working with an XML request, you can view it as text or in a grid.

    Enter the request body manually, or load it from a file or other sources.

    For details, see:

Back to top

Specify what to test in the CoAP server's response

Optionally, specify what status to expect in response to the request, as well as what response content:

  1. In the Properties pane, open the Input/Checkpoints tab to edit the Checkpoints.

  2. Configure any relevant checkpoints on the following properties:

    Status code, Status description. Use the CoAP response code reference for possible values. For example:

    • Error codes that begin with 2 imply success
    • Error codes that begin with 4 indicate failure
    • Error codes that begin with 5 indicate a server error

    Response body. The content of the response.

    For details on configuring checkpoints, see <checkpoint list> .

  3. You can specify additional validation of the response body in the CoAP tab in the Properties pane.

Back to top

Optionally, define event handlers to run in addition to the step

When creating or editing a test, you can use event handlers to test non-standard behavior of your application's API. You can add code activities to run before the step, after a response is received (CodeCheckPointEvent), or after the step ends.

For details, see Open a window for writing custom code.

Back to top