CentraSite 10.7 | CentraSite User’s Guide | Asset Management | Managing Assets through CentraSite Business UI | REST Service Management | Adding REST Service from Scratch | Adding Parameter to REST Service
 
Adding Parameter to REST Service
Parameters are used to pass and add additional information to a request. You can use parameters as part of the URL or in the headers or as part of the message body.
Multiple parameter types exist - the most widely used parameters are path and query-string parameters.
*Path parameters, which are integral part of the request URL and correspond to the URL path variable names.
The following example shows the path parameter representations and the result expected:
GET /phones/412456 - Returns the details for a specific phone whose product code is 412456.
In the above snippet, the URL path variable name 412456 is passed as a parameter to the GET method.
Note:
CentraSite allows you to define a path parameter only at the Resource level.
*Query-String parameters, which are passed as the request URL query parameters.
The following examples show the different query-string parameter representations and the results expected:
*GET /phones?make=apple - Returns a list of all the phones that match the specified brand Apple.
*GET /phones/412456?format=JSON - Returns the details for phone whose product code is 412456 in the JSON format.
*Header parameters, which are passed as custom HTTP headers.
The following example shows the header parameter representation:
GET /phones?412456
Accept-Encoding: application/json
x-CentraSite-ServiceKey:66f4b263-cc6e-11e3-85a7-a2d064a5bd02
*Form parameters, which are encoded as the POST part of the request message body.
Important:
Although CentraSite allows you to define parameters of the type "Form" at the REST Service level, these parameters are not supported at run-time.
In this task, you define input parameters either at the REST Service level, REST Resource level, or the REST Method level. Defining a parameter at the REST Service level (in the Technical Details profile) means that it is inherited by all Resources, and by all methods under the individual Resources. Defining a parameter at the Resource level (in the Add Resource dialog box) means that it is inherited by all Methods under it. Defining it at the Method level (in the Add Method dialog box) only applies the parameters to that particular method; it does not affect either the REST Service level or Resource level.
*To add a parameter
1. In CentraSite Business UI, access the Advanced Search panel in one of the following ways:
*Click the Browse link in the upper-left corner of the menu bar.
*Click the Search icon next to the Scope list. The default search scope is Assets.
This displays a list of assets in the Search Results page.
2. In the Additional Search Criteria list, select Asset Types.
3. To search for the assets of type, REST Service, click Choose.
This opens the Choose Asset Types dialog box.
4. In the Choose Asset Types dialog box, select the Assets option button, and perform the following:
a. Click the chevron next to Assets option button.
A list of defined asset types in CentraSite is displayed.
b. In the list of asset types, select REST Service.
c. Click OK.
A list of defined REST Service assets is displayed in the Search Results page.
5. Click the REST Service you want to add the REST Parameter.
This opens the REST Service details page. Also, the Actions bar displays a set of actions that are available for working with the REST Service.
6. On the Actions bar of the REST Service details page, click Edit.
7. Select the Technical Details, Components or Resource and Methods profile.
8. Click the chevron next to the Parameters in the Technical Details profile, or Parameters in the Components profile, or the Add Resource dialog box, or the Add Method dialog box, as required.
Note:
When you add parameters from the Resource and Methods profile, you can select an existing global parameter defined on the Components page.
9. Click the Add Parameter link.
This opens the Add Parameter dialog box.
10. In the Add Parameter dialog box, provide the required information for each of the displayed data fields.
Field
Description
Name
Name of the REST Parameter.
Description
(Optional). The description for the REST Parameter.
Parameter Type
The type of REST Parameter. The supported types include:
*Path
*Query-String
*Header
*Form
Data Type
The data type of the REST Parameter.
Required
Specifies if the parameter is mandatory or optional for invoking the REST Service.
Array
Specifies if the parameter can hold a single value or an array of values.
Possible Values
(Optional). A list of possible values for the REST Parameter.
Default Value
(Optional). A default value for the REST Parameter.
The newly created REST Parameter is added to the REST Service, or the REST Resource, or the REST Method.
11. Click the chevron next to the REST Parameter for which you want to display the details.
12. To further update the new REST Parameter, hover over the required Parameter, and click the Edit icon. Repeat for each Parameter for which you want to modify the details.
13. To specify multiple REST Parameters, click the Add Parameter link, and provide values for the new REST Parameter.
14. Click Save.