Querying REST Service Results

The SecureRESTServiceWrapper and RESTServiceWrapper objects can be used to query results from a REST service without the need to display the REST Grid widget on a custom form.

Both JSON data and XML (POX) data are accepted. For JSON data, the results of the REST service are evaluated as a JavaScript object.

Note: See REST Grid Widget for widget information.

SecureRESTServiceWrapper

SecureRESTServiceWrapper is written to always use proxy ID to ensure that the REST service call is secure. This object defines the REST service to query through parameters as described in the following table.

Name Type Description
url String Required. Base URL of the service to query
ID String Custom endpoint ID
applicationId String Application ID
jsonResponse Boolean This controls whether JSON responses are evaluated in the JavaScript using the JavaScript Eval() method. If this parameter is not supplied, it is considered to be true.

For more information and an example using the SecureRESTServiceWrapper object, refer to Serena Central.

For information on the functions, refer to the following sections:

get

post

RESTServiceWrapper

RESTServiceWrapper can be written to use proxy ID or to use basic authentication. This object defines the REST service to query through parameters as described in the following table.

Name Type Description
url String Required. Base URL of the service to query
username String User name to access the REST service, if authentication is required
password String Password to access the REST service, if authentication is required
useProxy Boolean This controls whether to access the REST service through the SBM proxy. The default value is false.
jsonResponse Boolean This controls whether JSON responses are evaluated in the JavaScript using the JavaScript Eval() method. If this parameter is not supplied, it is considered to be true.
For an examples of using the RESTServiceWrapper object, refer to Serena Central and solution S138336 in the Serena Support Knowledgebase.

For information on the functions, refer to the following sections:

get

post

get

This function returns data from a REST service. Its parameters are described in the following table.

Name Type Description
path String The service path on which to do a GET
queryString String The query string with which to do a GET
callback Function This is the JavaScript function to invoke when the REST data is returned. The first parameter will be the result data if success is true; otherwise, it will be the failure message. The second parameter is the user-defined tag as passed to the get call.
tag Depends on parameter A user-defined parameter to be passed to the callback along with the REST data
customHeaders Array An array of two-element arrays containing the name and value of each custom header to pass to the callback

post

This function posts data returned from a REST service to the custom form. Its parameters are described in the following table.

Name Type Description
path String The service path on which to do a POST
queryString String The query string on which to do a POST
callback Function The JavaScript function to invoke when the REST data is posted. The first parameter will be the result data if success is true; otherwise, it will be the failure message. The second parameter is the user-defined tag as passed to the post call.
tag Depends on parameter A user-defined parameter to be passed to the callback along with the REST data
customHeaders Array An array of two-element arrays containing the name and value of each custom header to pass to the callback