SBM ModScript Reference → Programming SBM ModScript → Application Objects → Object Types → RESTDataSource
This class reads records from the TS_RESTDATASOURCE table and invokes the described REST call. You can define REST Data Sources in SBM Composer, and then bind them to endpoints that are configurable per environment in Application Repository. You can set up a server to host custom behavior written in any programming language (C#, Java, Groovy, Python, etc.) and SBM ModScript can interact with that server, either gathering data or invoking actions to be taken based on activity occurring in SBM. Because you can run SBM ModScripts during a transition, during a notification, or trigger them by a simple URL, this is a powerful integration point.
AppRecord->RESTDataSource
Return: (map) – Map that contains the URL parameters.
Override the default timeout by changing the value of Shell.RESTTimeout()—the expected value is an integer number of seconds.
Output: out (string) – Filled with the resulting data from the REST call. If JSON, consider using from_json to parse this value.
Input/Output: (vector) params - An optional Vector of Pair values of URL parameters, with values that you want to have bound to the URL parameters in a "first=second" format. Values that match URL parameters from the RESTDataSource URL will override the values from the URL, while values that do not match existing URL parameters will be appended to the URL.
Return: (bool) – Returns true if the call succeeds.
Override the default timeout by changing the value of Shell.RESTTimeout()—the expected value is an integer number of seconds.
Output: out (string) – Filled with the resulting data from the REST call. If JSON, consider using from_json to parse this value.
Input: sPostData - Data to send in the POST call. Potentially, set up the data to send in maps and vectors, then call to_json to prepare a JSON value to pass into this parameter.
Input/Output: (vector) params - An optional Vector of Pair values of URL parameters, with values that you want to have bound to the URL parameters in a "first=second" format. Values that match URL parameters from the RESTDataSource URL will override the values from the URL, while values that do not match existing URL parameters will be appended to the URL.
Return: (bool) – Returns true if the call succeeds.
Example:
var result = " ";
//Create AppRecord of RESTDATASOURCE table
var restSource = Ext.CreateAppRecord(Ext.TableId("TS_RESTDATASOURCE"));
restSource.ReadByColumn("TS_NAME", "JSONPlaceHolder1");
try {
restSource.Get(result);
} catch(e) {}
To view a script that provides sample code for working with the object returned from from_json(), refer to the RESTDataSource.tscm script in the installDir\SBM\Application Engine\ModScript_Examples directory on the Application Engine server or see Sample Five: RESTDataSource.
Copyright © 2007–2017 Serena Software, Inc., a Micro Focus company. All rights reserved.