Mapping Template Body Parameters

You can use this feature when you want to define the body of the API request. When you want to get the data from the server, you issue the API request in the form of a URL string. The Get-type request does not have a request body.

When you want to update or create data on the server, you use the Post method. To update or create data, you need to define the body of the request. The API request’s body contains the actual data that the API inserts into the server or creates it on the server.

To define the API request’s body:

  1. Under API Type, click the Template Body Parameters Mapping tab, and the application displays the group of boxes and list.
  1. Under Parameter 1, enter the details of the parameters as follows:
BoxDescription
NameIn this field, enter the name of the parameter (for example:- userName) that you have defined in the code of the API.
Source of ValueClick this list and then select the source type (for example: – REQUEST_BODY) from where the value of the template parameter is fetched.

To know more about all types of sources, see: Selecting Source of Value.
ValueIn this field, enter a parameter, a constant value, or an in-built value based on the value that you select in the Source of Value list. This parameter is mapped to the value or absolution JSON path of the related element (for example: – text box) in the application when you configure the API on an element (for example: – button).

If you have selected REQUEST_BODY or HEADER in the Source of Value list, two following cases describe how to define a parameter in the Value box.  

Case1:- (If you select  REQUEST_BODY in the Source of Value list)
a. In the Source of Value list, select REQUEST_BODY, and the Value box displays the dollar character ($).
b. In the Value box, enter a parameter after the dollar character ($) as follows:  

#Sample parameter path (JSON Path):
$.User_Name

c. Click Save to successfully configure API’s body parameter.

Case2:- (If you select  HEADER in the Source of Value list)
a. In the Source of Value list, select HEADER.
b. Click the Value list to display the list of parameters that are defined in the application request.
c. In the list, select the parameter or enter the name of the parameter manually (If you do not find the parameter in the list).

 
d. After you enter the parameter, click Save to configure the parameter.


Use DefaultIf you click this check box, the Default Value box opens. In the Default Value box, enter a value that the template parameter will store by default.
MandatoryIf you click this check box, the Mandatory Message box opens. In the Mandatory Message box, enter an error message that the application will display if the mandatory parameter does not store a value.
  1. To configure other parameters of the template body, click Add New Body Param Details and then perform the steps that are described in the last table.
  2. After you add all the parameters, click Save to configure the template body parameters.
Was this article helpful?
YesNo