Skip Navigation
Expand
ROQL in Browser Agent UI extension workspace
Answer ID 11848   |   Last Review Date 04/09/2022

How do I use the REST API in BUI extensions?

Environment:  

Browser UI (BUI) Extensions

Issue:  

The queryResults endpoint can be used to initiate ROQL queries.


  https://your_site_interface/services/rest/connect/version/
  queryResults/?query=semicolon-separated ROQL queries

Resolution:  

The workspace extension is able to call the Fetch API. Fetch is then able to make REST API requests; much like ajax. Both of these will work when interacting with the REST API.

 

Notes: 

The example below shows how to setup a basic fetch request using the extension_loader in a workspace extension. You will need the session token taken from GetSessionToken in order to call the REST API. The Session token will need to be included in the Authorization header.

  
ORACLE_SERVICE_CLOUD.extension_loader.load("test_fetch" , "1")
	.then(function(extensionProvider)
		{
			extensionProvider.getGlobalContext().then(function(gc) {
            const rest_url = gc.getInterfaceServiceUrl('REST');
      		const rURL = `${rest_url}/connect/latest/""ENDPOINT""
            gc.getSessionToken().then(function(sessionToken) {
				return fetch(rURL, {
                  method: "GET",
                  headers: new Headers({
                    "Content-Type": "application/json",
                    "OSvC-CREST-Application-Context": "default",
                    Accept: "application/json",
                    Authorization: "Session {session token}"
                  }),
                })
                .then(function(response) {
                  console.log("response status: ", response.status);
                  response.json().then(function(json) {
                    console.log(json);
                  });
                })
                .catch(function(err) {
                  return console.log(err);
                });
               });
              }
			});
		});

The extension configuration can be found in the Agent Browser UI Extensibility Framework Developer Guide

When using the config SEC_PAPI_INTEG_HOSTS_REST in conjunction with the REST API in BUI; please do be aware that the IP used will be that of the logged-in User.

The sample code in this document or accessed through this document is not certified or supported by Oracle. It is intended for educational or testing purposes only. Use of this sample code implies acceptance of the License Agreement.

 

File Attachment