Skip Navigation
Expand
ROQL in Browser Agent UI extension workspace
Answer ID 11848   |   Last Review Date 06/21/2021

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)
			{
				return fetch("URL", {
                  method: "GET",
                  headers: new Headers({
                    "Content-Type": "application/json",
                    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.

 

 

File Attachment