Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

invokeRestApi(routeKey, optionsObject, context)

Updated on July 20, 2021

Invokes a specific Pega REST API using a route key.

Returns

The REST API as a promise.

Parameters

NameTypeDescriptionRequired
routeKeystringThe identifier for the REST API to be invoked.
optionsObjectRestApiOptionsObjectThe object containing the options to be provided for the REST API to be invoked.

For more details, see RestApiOptionsObject.

contextstringThe 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)) {
  }
});

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us