External Rendering
How can I bring OneSearch results to an external system?
You may find that OneSearch works so well that you want to send results to an external system for display. OneSearch includes a set of REST APIs that you can use to query a particular Searcher or Section in the context of a specified user.
First, you’ll need to visit YDS OneSearch->Install Global Components to install a small, globally scoped Script Include. This allows OneSearch to perform searches in the context of a specified user, ensuring your search sources are properly secured.
Next, visit YDS OneSearch->Docs & Settings to see a form annotation that lists the API endpoints, URL parameters, and Request Payload needed to return valid search results.
Using the REST API Explorer within ServiceNow or a utility like Postman is a great way to perform sample searches and see the format of returned results.
An example request to pull a single result from the sample KB section might look like:
In order to add a Filter or Order parameter to a query, you must add additional filterTerm and orderTerm data to the Request Payload as indicated below:
An abridged example response is below. Though it isn’t shown in the example response, all responses will also contain data about available filters for the search results, according to Section configuration. These can be used by external systems but require a more complex Request Payload.
To see examples specific to your environment, enable Debug logging at YDS OneSearch->Docs & Settings, and then open OneSearch in a browser with the console log exposed. As you navigate searches, filters, and order selections, the API calls being made will be reflected in the console.
Any time you have an issue, a question, or an idea to make OneSearch better, don’t hesitate to reach out to us at yansalabs.com/support. We’re here to help!
Last updated