Creating dynamic URI in rest service in rest and json plugin

Creating dynamic URI in rest service in rest and json plugin

book

Article ID: KB0082586

calendar_today

Updated On:

Products Versions
TIBCO ActiveMatrix BusinessWorks Plug-in for REST and JSON 2.0.0

Description

The customer may be needing the dynamic URI in which based on the input value the customer may need to pull the information based on some ID which needs to be passed in the Invoke rest API pallet's. The developers may also need the a flexible way to parameterizing resource path.

Issue/Introduction

Creating dynamic URI in rest service

Environment

BusinessWorks.

Resolution

The above mentioned requirements can be achieved by defining the parameters style as template in the resource section of the rest and dispatch activity. 

For example in the "v1/vehicle/stockNumber" path the "stockNumber" needs to be defined as variable in the resource path then it should be defined as "<ns0:param name="stockNumber" style="template" required="true"/"> which means in the UI of the "REST Dispatch and Reply" activity under the "Service Editor" tab "RestService"-->"Resource"-->"Resource Path" should be provided as v1/vehicle/{stockNumber} and in the "Parameters" section the name should be defined as stockNumber and the style should be selected as template.

And while calling the service from the invoke rest api you can call the service created as below :- 

http://localhost:57425/v1/vehicle/7

Where "7" is the stockNumber.

For more the implementation you can refer to the "SampleProject.zip" which is attached to this article.

Attachments

Creating dynamic URI in rest service in rest and json plugin get_app