invokeRestApi(routeKey, optionsObject, context)
Invokes a specific Pega REST API using a route key.
Returns
The REST API as a promise.
Parameters
Name | Type | Description | Required |
routeKey | string | The identifier for the REST API to be invoked. | ✅ |
optionsObject | RestApiOptionsObject | The object containing the options to be provided for the REST API to be
invoked. For more details, see RestApiOptionsObject. | ✅ |
context | string | The name of the context where the API is being called. | ✅ |
Usage example
In this example, the API calls a REST API to get Feed messages.
const { invokeRestApi } = PCore.getRestClient();
const cancelTokenSource = getCancelTokenSource();
invokeRestApi('getFeedMessages', {
queryPayload: {
filterForContext: 'DATA-PORTAL $SpaceTra',
filterByContext: 'context'
},
body: {},
headers: {},
cancelTokenSource: cancelTokenSource.token
})
.then(() => {
})
.catch((error) => {
if(isRequestCanceled(error)) {
}
});
Previous topic getHeaderProcessor() Next topic isRequestCanceled(err)