Request body
Last updated
Last updated
A Request body is the data received by a Langstack API application from the endpoint in the network (i.e. client).
A Request body in an API contains the details of the request received by the API.
The user can access the received request body through the Request variable (shown in the image below), which contains the request body(s) defined under the Request body section.
The Request variable holds the payload for the request (i.e., the actual message or data received in the request).
A Request body comprises the following fields:
Request body Name: The name of the request body, this name will be used when accessing it in the Actions.
Content Type: The content type is the format of the content that is expected in the request body. For example if the content type is application/json then the sample section should contain a JSON.
Character Set: The character set defines the content that the request is received with.
Description: This field explains the purpose of the request body. This text is visible in the API documentation.
Copy Sample from Entity: This field is used to copy a sample json object from an existing entity into the Sample Box.
Sample Box: The Sample Box contains a sample of the request that matches the Content-Type. For example if the content type is application/json, the user must provide a Json sample which can be entered directly or copied from an existing entity by using the drop-down “Copy Sample from Entity”. The sample should be similar to the expected Json to be received.
Users may define multiple request bodies in an API to handle multiple content types. However, only one of the defined request bodies will contain the received request data depending on the Content-Type.
For example, suppose a request can be received in XML and Json format. In that case, a request body may be defined to receive XML requests, and another request body may be defined to receive Json requests but for one request, only one of them will receive the request depending on the Content-Type received.