Pass REST service properties

Relevant for: API testing only

When creating or editing a REST service, you may want to define the value of a URL property or a custom input or output property at the service or resource level in order to make this value available for all resources and methods included in the service or resource. For example, if your REST service resources/methods all reference the same URL prefix, you can define the value of URL property at the service level and pass the URL property value to all resources and methods.

You can also define custom input and output property names and values at all levels of the hierarchy and pass these input and output properties and their values through the REST service hierarchy. For details on creating custom input and output properties, see Define custom properties - optional.

After a URL property value is defined at a higher level, you can define other (relative) additions to the URL property value for any of the resources and methods included in the service. These adjusted relative URL values are concatenated to the URL property value received from higher levels of the hierarchy and the adjusted values are passed to all levels below it. For example, if you add a URL property value at the service level, you can append relative URL paths for a selected resource or method. The URL property value passed from the service level is then concatenated with the relative URL property value added at the resource or method levels.

Note: You cannot modify URL property values passed down from a higher level of the REST service hierarchy. You can only add to them with a relative URL value.

After you add additional relative URL property values at lower levels of the hierarchy, such as at the resource or method level, you must assure that the full URL is a proper URL. For example, if you define the URL property value at the resource level with http://, the relative URL property value appended at the method level should not also use a http:// prefix.

Example:  

You define a URL property value for the REST service at the service (top) level: http://flights.api.com. This value is then passed to any resources and methods within this REST service.

You also create a resource for this service, called Flight Reservation. You define the relative URL value as /reserve. This relative URL property value is then concatenated with the URL property value passed from the service level to create a URL for the resource: http://flights.api.com/reserve. This URL property value can also pass to any methods created for the resource.

You then create a method for the Flight Reservation resource, called GetFlights and define the relative URL property value for this method as /getflights. This value is then further concatenated with the URL passed from the resource to make a complete URL for the method: http://flights.api.com/reserve/getflights.

These properties and custom input or output properties then serve as a prototype template for the REST service, and you can edit the URL property values or custom input and output property values after adding the method activities to the canvas.

Note: The relative URL is not displayed on the REST method when it is included in a test in the canvas. Only the full, concatenated URL for the method displayed in the Add REST Service dialog box is displayed in the Properties pane for the selected method.