Get aggregate rating result

get

/km/api/v1/content/{id}/ratingsAggregate

This method returns the AggregateFormResults object that represents all of the rating responses for the specified Content translation. The AggregateFormResults object includes the rating's questions and answers displayed in the Locale specified with the request.

You can specify the Locale by setting the localeId parameter of the kmauthtoken header when making requests to the Oracle Knowledge REST API. Alternatively, if no localeId parameter value is specified, then the method interprets the specified Locale as the default Locale object assigned to the logged-in user. In both the cases, the specified Locale is referred to as the session's Locale. The logged-in user is the user for which the userToken attribute on the kmauthtoken header was created. Additionally, the Locale can be specified by the langpref request parameter.

The method sums the response for each question and computes the average rating for ratings of type five-star for the Content object for the specified Locale. Rating types other than the five-star rating have zero as the value of the average rating.

NOTE: A Content object can be rated only for a specific Locale. Thus, the method returns a different AggregateFormResults object for the same Content object when the request is made with different Locale objects.

Example URIs

Following are the example URIs for this method:

  • http://<IM_REST_API_HOST>/km/api/latest /content/{id}/ratingsAggregate

    The request returns an AggregateFormResults object for the specified Content object, translated in the session's locale.

  • http://<IM_REST_API_HOST>/km/api/latest/content/{id}/ratingsAggregate?langpref=es_ES

    The request returns an AggregateFormResults object for the specified Content object, translated in the request's locale.

Response Errors

  • OKDOM-GEN0001

    The error occurs when an invalid id has been given.

  • OKDOM-SURV0018

    This error occurs when no rating defined for a content type.

Request

Path Parameters
Back to Top

Response

Supported Media Types

200 Response

OK.
Body ()
Root Schema : AggregateFormResults
Match All
Show Source
Nested Schema : AggregateFormResultsData
Match All
Show Source
Nested Schema : AggregateFormResultsKey
Match All
Show Source
Nested Schema : Singular Resource
Type: object
Title: Singular Resource
Oracle base singular resource schema definition.
Show Source
Nested Schema : AggregateFormResultsKey-allOf[1]
Type: object
Show Source
  • The unique record ID of the AggregateFormResults object.
  • The reference key for the AggregateFormResults object. AggregateFormResults objects support multiple languages. This field can be used to identify the associated objects for all languages.
Nested Schema : AggregateFormResultsData-allOf[1]
Type: object
Show Source
Nested Schema : AggregateFormResults-allOf[1]
Type: object
Show Source
Nested Schema : questions
Type: array
To Many Relationship to AggregateQuestionResult
Show Source
Nested Schema : AggregateQuestionResult
Match All
Show Source
Nested Schema : AggregateQuestionResultData
Match All
Show Source
Nested Schema : AggregateQuestionResultKey
Type: object
Title: AggregateQuestionResultKey
Show Source
Nested Schema : AggregateQuestionResultData-allOf[1]
Type: object
Show Source
Nested Schema : AggregateQuestionResult-allOf[1]
Type: object
Show Source
Nested Schema : answers
Type: array
To Many Relationship to AggregateAnswerResult
Show Source
Nested Schema : AggregateAnswerResult
Match All
Show Source
Nested Schema : AggregateAnswerResultKey
Type: object
Title: AggregateAnswerResultKey
Show Source
Nested Schema : AggregateAnswerResult-allOf[1]
Type: object
Show Source
Back to Top

Examples

The following example shows how to find the Aggregate Form Results object that represents all of the ratings responses for the specified Content translation by submitting a get request on the REST resource using cURL.

cURL Command

Command: curl -X "GET" "http://<IM_REST_API_HOST>/km/api/latest/content/{id}/ratingsAggregate"

Example of Request Header

The following shows an example of the request header.

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

Example of Response Body

The following shows an example of the response body in JSON format.

{
  "questions" : [ {
    "answers" : [ {
      "totalResponses" : 3,
      "recordId" : "048016503b35e6fc0144e01818e2006b18",
      "referenceKey" : "A4",
      "name" : "4"
    }, {
      "totalResponses" : 1,
      "recordId" : "048016503b35e6fc0144e01818e2006b19",
      "referenceKey" : "A2",
      "name" : "2"
    }, {
      "totalResponses" : 1,
      "recordId" : "048016503b35e6fc0144e01818e2006b1e",
      "referenceKey" : "A3",
      "name" : "3"
    }, {
      "totalResponses" : 1,
      "recordId" : "048016503b35e6fc0144e01818e2006b21",
      "referenceKey" : "A5",
      "name" : "5"
    }, {
      "totalResponses" : 1,
      "recordId" : "048016503b35e6fc0144e01818e2006b22",
      "referenceKey" : "A1",
      "name" : "1"
    } ],
    "recordId" : "048016503b35e6fc0144e01818e2006b24",
    "referenceKey" : "Q1",
    "name" : "How would you rate this document?",
    "totalResponses" : 7,
    "averageResponse" : 3.2857142857142856
  } ],
  "recordId" : "048016503b35e6fc0144e01818e2006b20",
  "referenceKey" : "FIVE_STAR_RATING",
  "links" : [ {
    "rel" : "canonical",
    "href" : "http://<IM_REST_API_HOST>/km/api/{version}/{resourceURI}",
    "mediaType" : "application/json, application/xml",
    "templated" : true,
    "method" : "GET"
  } ],
  "totalResponses" : 7
}
Back to Top