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

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>

&lt;structure ref-name="trips" name="trips_data"&gt; 
	&lt;property name="trip_name" type="string"/&gt;
	&lt;property name="destination" type="string"/&gt;
	&lt;property name="start_time" type="datetime"/&gt;
	&lt;property name="end_time" type="datetime"/&gt;
	&lt;property name="no_of_days" type="string"/&gt;
&lt;/structure&gt;

</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