Skip Navigation
Expand
Using Console Users with Knowledge Advanced Search REST API
Answer ID 10230   |   Last Review Date 07/24/2019

How do I use the OKCS Search REST API with a Console User?

Environment:

Oracle B2C Service Knowledge Advanced
Search REST API

Issue:

The application I am building uses the Search REST API and needs to support question and answer results that are user group restricted.  

Resolution:

A full sequence will require using values from the responses in the next request in the sequence. All Responses and tokens truncated for example purposes.

  1. Retrieve an Integration Token using the API User and password.
    • Headers: ["accept: application/json","content-type: application/json","cache-control: no-cache","kmauthtoken:{"siteName":"<sitename>","localeId":"en_us"}"]
    • Body: {"login":"apiauthor","password":"<password>","siteName":"<sitename>"}
    • Endpoint: https://<site rest url>//km/api/latest/auth/integration/authorize
    • Response: {"authenticationToken":"bGl2ZXRlc3RfMT"}
  2. Retrieve a User Token for Console Users -- url parameter ACCOUNT, or Web Users -- url parameter CONTACT.
    • Headers: ["accept: application/json","content-type: application/x-www-form-urlencoded","cache-control: no-cache","kmauthtoken:{"siteName":"<sitename>","localeId":"en_us","integrationUserToken":"bGl2ZXRlc3RfMT"}"]
    • Endpoint: https://<site REST url>//km/api/latest/auth/authorize
    • Url params: userName=<consoleUser>&password=<password>&siteName=<sitename>&userExternalType=ACCOUNT
    • Response: {"authenticationToken":"{"localeId":"en_US","siteName":"<siteName>",integrationUserToken":null,"userToken":"92mFh9S9WleW2Kq"},"user":{"isActive":true,"isLocked":false,"adminUser":true,"login":"<user login>","recordId":"<user record ID>","name":"<user Name>","externalId":<ID>,"externalType":"ACCOUNT"}}
  3. Begin a search session using the Initial Screen:
    • Headers: ["accept: application/json","content-type: application/json","cache-control: no-cache","kmauthtoken:{"siteName":"<sitename>","interfaceId":"1","integrationUserToken":"bGl2ZXRlc3RfMT","userToken":"92mFh9S9WleW2Kq"}"]
    • Body: {"transactionId":0,"locale":"en-US","resultLocales":"en-US","session":1}
    • Endpoint: https://<site search rest url>/srt/api/latest/search/initialScreen
    • Response: {"results":{"results":[],"facets":[]},"session":"159090e7441c65","transactionId":0,"priorTransactionId":-1}
  4. Ask a question using the search/question endpoint
    • Headers: ["accept: application/json","content-type: application/json","cache-control: no-cache","kmauthtoken:{"siteName":"<sitename>","interfaceId":"1","integrationUserToken":"bGl2ZXRlc3RfMT","userToken":"92mFh9S9WleW2Kq"}"]
    • Body: {"session":"159090e7441c65","locale":"en-US","resultLocales":"en-US"}
    • Endpoint: https://<site search REST url>/srt/api/latest/search/question%3Fquestion%3D<search Terms>
    • Response: {"session":"159090e7441c65","transactionId":0,"priorTransactionId":0,"title":"gold users only","url":"IM:SLA_RESTRICTED:128022103a:en_US:published:SLA3:10001824:1.0","documentType":"CMS-XML","HttpPassThrough":"{"recordId":"128022103a","versionId":"128022103a","documentId":"SLA3","title":"gold users only","version":"1.0","answerId":1000182,"locale":{"recordId":"en_US","links":null},.....

Notes:

For further information your site specific parameters, such as siteName, site REST url, site search REST url, API user, and other user types contact your main site adminstrator

For further information on the Search REST API
Knowledge Advanced Search REST API Endpoints
Knowledge Advanced REST API Authenticate and Authorize

Available Languages for this Answer:

Notify Me
The page will refresh upon submission. Any pending input will be lost.