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.
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:
-
In the Properties pane, open the Input/Checkpoints tab to edit the Input.
-
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>
- Select the CoAP Method to send. Possible values: GET, POST, PUT, DELETE.
- Optionally, in the Accept box, select the type of data UFT should expect to receive from server. For example, application/xml or application/json.
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.
-
In the Properties pane, open the General tab .
-
Optionally configure the step Name and the following properties:
Message type. Indicates whether to use Confirmable or Non-confirmable messages. By default UFT One uses Confirmable messages.
Timeout. In milliseconds (Default=2000)
Create the body of the request
Provide the body content of the request that this step sends to the CoAP server:
-
In the Properties pane, open the CoAP tab.
-
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:
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:
-
In the Properties pane, open the Input/Checkpoints tab to edit the Checkpoints.
-
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> .
- You can specify additional validation of the response body in the CoAP tab in the Properties pane.
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.