Invoke the Knowledge Advanced REST APIs from Customer Portal
You can invoke both the Knowledge Advanced content (IM) and search REST APIs directly from Customer Portal using the OKCS API model. The OKCS API model is located in /cp/core/framework/Models.
The OKCS API model includes a public makeApiRequest
method. You can write custom code to instantiate the model class,
then call the makeApiRequest
method to invoke a content
(IM) or a search API. The response is stored in the $apiResponse
variable, which can be consumed as required. You can include the
custom code within a custom PHP page or a custom widget.
makeApiRequest
method has three parameters.$url
− The API end-point URL of a REST API. Use\RightNow\Utils\Config::getConfig(OKCS_IM_API_URL) . '<resource_URL>'
to invoke a content (IM) API and\RightNow\Utils\Config::getConfig(OKCS_SRCH_API_URL) . '<resource_URL>'
to invoke a search API.$methodName
− Method name is the type of method request, including GET or POST.$postData
− Post data is an array of variable names and values in the body of the request message sent by the POST method.
You can find the complete list of Knowledge Advanced content (IM) and search resource URLs in the Tasks section of the REST API for Knowledge Advanced in B2C Service guide.