Request Body
It defines the request-body details for a particular operation. You can add multiple <content> under this element to achieve the request body in different encodings.
Possible Locations
Child Elements
- Description
- Content required recurrent
Attributes
Name | Type | Description |
---|---|---|
name required |
String | Name of the request-body. |
Note:
The attribute name is mandatory only when the request-body is a child of <components>.
Example
Assume that we want to build a request body for the CREATE operation of trips resource with the following details,
copy
Sample request JSON:
{
"trips": [
{
"trip_name":"Spring Break - John Doe",
"destination": "Bali",
"start_time": "2023-11-13T17:30:00",
"end_time": "2023-11-17T22:30:00",
"no_of_days": 4
},
{
"trip_name":"christmas Break - Diana Williams",
"destination": "London",
"start_time": "2023-12-20T21:30:00",
"end_time": "2023-12-28T09:30:00",
"no_of_days": 7
}
]
}
Here is how you have to write the request body for the above requirement. The first step is to declare the primary structure in the <components>.
copy
<components>
<structure ref-name="trips" name="trips_data">
<property name="trip_name" type="string"/>
<property name="destination" type="string"/>
<property name="start_time" type="datetime"/>
<property name="end_time" type="datetime"/>
<property name="no_of_days" type="string"/>
</structure>
</components>
Now define the request body as follows,
copy
<request-body>
<content>
<encode type="application/json" />
<structure>
<property name="trips" type="collections">
<structure-ref name="trips" />
</property>
</structure>
</content>
</request-body>
Last Updated 2025-05-30 16:54:59 +0530 IST
Yes
No
Send your feedback to us
Skip
Submit