Response

This element defines the response related information of an <operation>. You can add multiple <content> to the response with different encodings based on your requirement.

Possible Locations

Child Elements

Attributes


Name Type Description
status
required
Integer Defines the status codes of the response. ZEST supports all the global HTTP response status codes. Check here for the standard status codes.
name
required
String Name of the response.
visibility String (enum) Decides who can view and use the element. The possible values are internal, private, public. The default value is public.
unexpected-error Boolean It stands for the unhandled errors (internal server error) in your resource.
  • true: It represents the response, which is configured for the unhandled errors (status code: 500).
    In Automation, this response will be treated as a failure test case.
  • false (default): It represents the response, which is configured based on requirements.

Note:

The name attribute is mandatory for response only when it is added under <components>.

Example

Following is a sample response JSON of the GET operation for trips resource.

    
copy
success response { "trips": [ { "trip_name":"Spring Break - John Doe", "trip_id":"5545974000000087515", "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", "trip_id":"5545974000000087565", "destination": "London", "start_time": "2023-12-20T21:30:00", "end_time": "2023-12-28T09:30:00", "no_of_days": 7 } ] }
    
copy
"Content-Language" argument: value is "en-US"

The very first step is to define the primary structure in the <components>.

    
copy
<components> <structure ref-name="trips" name="trips_data"> <property name="trip_name" type="string"/> <property name="trip_id" type="long_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 response with all these details.

    
copy
<response name="get_success" status="200"> <description> This is the response of an overall fetch of Fields API resource. </description> <content> <encode type="application/json" /> <structure> <property name="trips" type="collections"> <structure-ref name="trips" /> </property> </structure> </content> <argument name="response_argument" location="header" required="true"> <content> <encode type="application/json" /> <structure> <property name="Content-Language" type="string" values="en-US" /> </structure> </content> </argument> </response>

Last Updated 2025-05-30 16:54:59 +0530 +0530