How to define pass parameters to a UX REST Data Broker?

David Hubbard
Tera Guru

I'm trying to use an existing REST API in UI Builder via UX REST Data Broker (sys_ux_data_broker_rest).

When I add this into UI Builder I can see result data - meaning (I think) it made a request

But no option is provided to pass a parameter to this - how do I define/pass the parameter? 

I have tried adding JSX definitions to properties and parameters - but not sure how to tell UI Builder about the parameter that needs to be provided.

 ### UPDATE

I have got an inch closer.

I found that the "Properties" is an Array

Now the ID field appears in UI Builder.

However even with a specific sys_id in that field (one that does return a user on an HTTP request via Postman) returns empty array.

So the question is now (I think) : How to define the "API" parameter in the 'sys_ux_data_broker_rest'?

If I have tried

  • hard coding the id in the API URL - I get data.
  • however other forms all fail
    • "{id}" - the standard REST API definition form
    • "%id"
    • "$id"

 

 

 

1 ACCEPTED SOLUTION

lakshminarayan4
ServiceNow Employee
ServiceNow Employee

All is good except your url parameters should contain double curly braces paramters. See the example belowfind_real_file.png

View solution in original post

6 REPLIES 6

Community Alums
Not applicable

Hello - using the instructions, I was able to successfully configure a REST data resource which is fetching the data and showing in the preview node in UIB.

However, when I open the page for real-time testing, nothing is happening.

I created an execute ACL for the sys_ux_data_broker_rest record. Still nothing is happening
I am able to prove that the REST call is not being made when the page is rendered.
However the REST call is successfully made in the preview mode in UIB.

This proves that the theory works in UIB but is not practically working when I am rendering the page.

What am i missing?
Please advise....thanks in advance.

Hi - I don't know the answer - but something I have learnt is to avoid the "eager" mode and use "explicit" instead.

To do that you will need to:

a) Check the "Mutates Server Data" checkbox on the REST Definition (top right of screen), then refresh your UIB

b) data resource should only show "Explicit" as an option now.

c) If you want to run it on page load (or after another resource is loaded) then you will need a client script to execute

api.data.my_rest_broker.execute({
   parm: my_parm_value
});

Link this to (for example) the Page Ready event on the Page.

Then handle the result in another client script linked to the "Operation Succeeded" event in the data resource.

Data should be available in `event.payload`.

I should indicate that after having quite a few issues with using REST mechanisms into our REST API in our app I have switched to using "Transform Data Broker" which is a little more obvious.