Walkthrough: Testing a Search and Recommendation API request in the API Explorer
How to test a Search and Recommendation API request using the API Explorer in Sitecore Discover Customer Engagement Console (CEC).
Sitecore Discover Customer Engagement Console (CEC) includes the API Explorer in the Developer Resources section. Using the API Explorer, you can build a JSON request and fetch data using a Discover Search and Recommendation API endpoint.
You will be using the API Explorer during this walkthrough to fetch data for the widgets on the Home Page. This walkthrough describes how to:
-
Build a request.
-
View and edit the request.
-
Save the request as a JSON data object.
-
Run request and save the response as a JSON data object.
Build a request
To build the request to fetch data to populate widgets on the Home Page:
-
To access the API Explorer in the CEC, go to Developer Resources, in API Explorer.
-
Click Reset to clear the form in the Builder panel of the API Explorer.
-
In the Builder panel, click Page drop-down and then click Home Page.
-
Enter / (backslash) as the URL for the Home Page.
-
Check All widgets to get data for all widgets on the Home Page.
-
Enter 10 for N_item to retrieve per widget.
-
Enter 1 for Page_number in case any of the widgets display paginated results.
-
Click Build.
View and edit a request
To view and edit the request"
-
Read the request in JSON format in the Request panel of the API Explorer. An error, visible above the JSON, says that
context.user.uuid
orcontext.user.user_id
is required. -
Open the Context/User section in the Builder panel. Enter 123456 for UUID.
-
Click Build.
-
Verify there are no more errors.
Save the request as a JSON data object
To save the request to a text file:
-
Read the request in JSON format in the Request panel of the API Explorer.
-
Click Copy to clipboard as... and select Copy as data object.
Run request and copy the response to text file
To run the request and copy the response:
-
Click Run.
-
Read the response in JSON format in the Response panel of the API Explorer. You can scaffold and scroll through the response.
-
Click Copy to clipboard as... and select Copy as data object.