Find categories by name

get

/km/api/v1/categories/findByName

This method returns a list of categories whose name matches with the passed in nameToken value. The method can be called to search for categories and products under a particular parent, in this case the parentId parameter is required. Alternatively the method can search for required or optional categories under a particular contentType by specifying the contentTypeId and the required parameters. The externalType parameter which can be either CATEGORY or PRODUCT is required for both search types. When caller sets the optional withNoChildren parameter to true, categories and products that have children will not be included in the response. When the caller sets the topLevelOnly parameter to true, the parentId search case is limited to the parent's immediate children on the content type search the results are limited to the root categories or products. Individual parameters are described in detail below.

If the user making this request is a contact only categories in the currently active view will be searched.

As mentioned the service takes in various request parameters. Please note this is applicable for both Products and Categories

  • parentId : The parentId of the Category. If parentId is passed then the search will happen in that parent's context. Optional parameter.
  • externalType : The externalType will determine if the caller is asking for Products and Categories. For categories set it to CATEGORY and for products set it to PRODUCT. Required parameter.
  • contentTypeId : When this is passed the code will do the search under the passed in ContentType. Optional parameter.
  • required : When this is set the code will do the search under the passed in ContentType which are marked as Required. Optional parameter.
  • nameToken : The text query for the name of the Product or Category. Together with nameTokenSearchType, user can set it different ways to locate matching names. Required parameter.
  • nameTokenSearchType : Name searching formats. It can be STARTS_WITH, ENDS_WITH and CONTAINS. Optional parameter.
  • withNoChildren : When this is set to true the search will return Categories or Products with no children. Optional parameter.
  • topLevelOnly : When this is set to true the search will only return Categories or Products that are at the immediate children level. Optional parameter.
Note:
  • At lease one and only one from parentId and contentTypeId should be passed.
  • Search is case insensitive, so nameToken=Aa or nameToken=aa or nameToken=AA will return same response.
  • Do not pass any wildcard characters,use the nameTokenSearchType instead.
  • For name matching, name in request locale will be used. Caller can override request locale using Accept-Lang header. If name does not exists in request locale, name in repository's default locale will be used.

This resource supports the withParents request parameter.

When the withParents request parameter is set to true, for each category returned the parent categories of that category will be included, ordered from the root category to the immediate parent of each returned category.

Possible Errors:

  • OK-GEN0030 - When the following fields are in mismatch combination:
    • both contentTypeId and parentId are not null and not empty.
    • parentId is not null and not empty and required is true.
  • OK-GEN0031 - When the following fields are NULL:
    • both contentTypeId and parentId are null or empty.
    • nameToken is null or empty.
  • OKDOM-GEN0006 - when nameTokenSearchType has invalid enum value.

The example URI to get schema and catalog of the resource is as follows:

  • http://<IM_REST_API_HOST>/km/api/latest/categories/findByName?parentId={parent_record_id_of_my_category}&externalType=PRODUCT&nameToken=phone
  • http://<IM_REST_API_HOST>/km/api/latest/categories/findByName?contentTypeId={content_type_record_id}&externalType=PRODUCT&nameToken=phone&required=true
  • http://<IM_REST_API_HOST>/km/api/latest/categories/findByName?contentTypeId={content_type_record_id}&externalType=PRODUCT&nameToken=phone&required=false&nameTokenSearchType=STARTS_WITH
  • http://<IM_REST_API_HOST>/km/api/latest/categories/findByName?contentTypeId={content_type_record_id}&externalType=PRODUCT&nameToken=phone&required=false&nameTokenSearchType=STARTS_WITH&topLevelOnly=true
  • http://<IM_REST_API_HOST>/km/api/latest/categories/findByName?contentTypeId={content_type_record_id}&externalType=PRODUCT&nameToken=phone&required=false&nameTokenSearchType=STARTS_WITH&topLevelOnly=true&withParents=true

Request

Supported Media Types
Query Parameters
Back to Top

Response

Supported Media Types

200 Response

OK.
Body ()
Root Schema : ResultList CategoryKey
Type: object
Title: ResultList CategoryKey
Match All
Show Source
Nested Schema : Collection Paging Resource
Title: Collection Paging Resource
Oracle base collection resource schema definition.
Match All
Show Source
Nested Schema : Base Collection Resource
Title: Base Collection Resource
Oracle base collection resource schema definition.
Match All
Show Source
Nested Schema : Singular Resource
Type: object
Title: Singular Resource
Oracle base singular resource schema definition.
Show Source
Nested Schema : Base Collection Resource-allOf[1]
Type: object
Show Source
Nested Schema : Collection Paging Resource-allOf[1]
Type: object
Show Source
Nested Schema : ResultList CategoryKey-allOf[1]
Type: object
Show Source
Nested Schema : items
Type: array
Show Source
Nested Schema : items
Type: object
Nested Schema : items
Type: array
Show Source
Nested Schema : CategoryKey
Match All
Show Source
Nested Schema : CategoryKey-allOf[1]
Type: object
Show Source
  • This field will return number of immediate children a category has.

    This field will only be populated if childrenCount query parameter is passed in with value true.

    Example URIs for the this parameter are as follows:

    • http://<IM_REST_API_HOST>/km/api/categories/{id}?childrenCount=true&mode=KEY
    • http://<IM_REST_API_HOST>/km/api/categories?childrenCount=true&mode=KEY
    • http://<IM_REST_API_HOST>/km/api/categories?q=contentTypeRefKey eq 'FAQ'&childrenCount=true&mode=KEY
  • Description of the Category object
  • The unique identifier used while integrating the repository data with the external system.

  • The type of the category used while integrating the repository data with the external system. Valid options are PRODUCT and CATEGORY.

  • The name of the category.

  • The hierarchichal position of the category
  • parents

    This field will return all parents of category.

    This field will only be populated if withParents query parameter is passed in with value true.

    Example URIs for the this parameter are as follows:

    • http://<IM_REST_API_HOST>/km/api/categories/{id}?withParents=true&mode=KEY
    • http://<IM_REST_API_HOST>/km/api/categories?withParents=true&mode=KEY
    • http://<IM_REST_API_HOST>/km/api/categories?q=contentTypeRefKey eq 'FAQ'&withParents=true&mode=KEY
    • http://<IM_REST_API_HOST>/km/api/categories/{id}?childrenCount=true&withParents=true&mode=KEY
  • The unique record ID of the Category object.

  • The reference key for the Category object. Category objects support multiple languages. This field can be used to identify the associated objects for all languages.

  • This is a custom field that will get populated if a name is translated into the default locale when the translated name is not found.

Nested Schema : parents
Type: array

This field will return all parents of category.

This field will only be populated if withParents query parameter is passed in with value true.

Example URIs for the this parameter are as follows:

  • http://<IM_REST_API_HOST>/km/api/categories/{id}?withParents=true&mode=KEY
  • http://<IM_REST_API_HOST>/km/api/categories?withParents=true&mode=KEY
  • http://<IM_REST_API_HOST>/km/api/categories?q=contentTypeRefKey eq 'FAQ'&withParents=true&mode=KEY
  • http://<IM_REST_API_HOST>/km/api/categories/{id}?childrenCount=true&withParents=true&mode=KEY
Show Source
Back to Top

Examples

The following example shows how to find a list of categories that match the specified category name by submitting a get request on the REST resource using cURL.

curl GET http://<IM_REST_API_HOST>/km/api/latest/categories/findByName

Example of Response Header

The following shows an example of the response header.

-H "kmauthtoken: {\"siteName\":\"ORACLE_KNOWLEDGE\",\"integrationUserToken\":\"+eCJYkxKwj5HUaIiJYun0/TpatwT1LmtcsF05W33xnEojifV/AsLDj9RpN0lKuorTMNKeSE1tgC7svVL+BzntqDON4KiM1HFlpxvXEUCB0P2w0Xrs75McygqxdVaDSE9"}" \
-H "Accept: application/json"

Example of Response Body

The following example shows the contents of the response body in JSON format:

{
  "items" : [ {
    "referenceKey" : "REFERENCEKEY_VALUE",
    "name" : "NAME_VALUE",
    "externalId" : 1428416790963,
    "externalType" : "EXTERNALTYPE_VALUE",
    "description" : "DESCRIPTION_VALUE",
    "links" : [ {
      "rel" : "canonical",
      "href" : "http://<IM_REST_API_HOST>/km/api/{version}/{resourceURI}",
      "mediaType" : "application/json, application/xml",
      "templated" : true,
      "method" : "GET",
      "profile" : "http://<IM_REST_API_HOST>/km/api/{version}/metadata-catalog/{resourceName}"
    } ]
  }, ],
  "hasMore" : false,
  "limit" : 20,
  "offset" : 0,
  "links" : [ {
    "rel" : "canonical",
    "href" : "http://<IM_REST_API_HOST>/km/api/{version}/categories?limit=20&offset=0",
    "mediaType" : "application/json, application/xml",
    "method" : "GET"
  } ],
  "count" : 1
}
Back to Top