Why do my search questions from the Knowledge Advanced Search REST API not show up in the analytics database tables?

Environment:

Oracle Service Cloud Knowledge Advanced
Search REST API

Issue:

The application I am building uses the Search REST API and performs authentication and session initialization to retrieve an integrationUserToken and session respectively. The questions that are asked via the Search REST API endpoints /search/question or /contactDeflection/question are not available in the okcs_stg_question, okcs_stg_annotation or okcs_stg_answers tables. The value of knowledgeInteractionId populates the session_ref colum in the okcs_stg_question and okcs_stg_annotation tables and the okcs_session_ref column in the okcs_stg_answers table.

Resolution:

Knowledge Advanced searches can be performed from anywhere using the Search REST API and are available in the analytics tables when the following is included in the request to the /question endpoint.

The full request must contain:

Headers

accept: application/json or application/xml

content-type: application/json or application/xml

kmauthtoken:{"siteName":"<sitename>","interfaceId":"1","localeId":"en-US","knowledgeInteractionId":"<value for session_ref>","integrationUserToken":"<token>"}

Generally, begin with the request elements listed as required in the documentation and beyond that only add elements specific to your application needs.

The interfaceId should be the ID of the interface on which you wish to search, not necessarily 1.

Use of the initialScreen endpoint for one-time session initiation is recommended as a best practice. Those sessions should not be reused between different users, such as those who are not logged in. Rather than using initialScreen, you could generate a search session by not supplying one in a call to the search/question endpoint and retain it for subsequent requests. However, the transactionId will always be 0 unless it is supplied in the body by the client in that same initial call. Hence, initialScreen is recommended as a best practice -- another benefit being that it has no required body parameters. The empty JSON string {} works for initialScreen.

When using navigation or pagination, you should always pass priorTransactionId as a query parameter and supply a different transactionId in each request body (e.g. incremented from the priorTransactionId).