Get aggregate rating result
/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
-
id: string
The content identifier.
Response
- application/json
- application/xml
200 Response
-
object
Singular Resource
Title:
Singular Resource
Oracle base singular resource schema definition. -
object
AggregateFormResultsKey-allOf[1]
object
Singular Resource
object
-
recordId(optional):
string
The unique record ID of the AggregateFormResults object.
-
referenceKey(optional):
string
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.
object
-
totalResponses(optional):
integer
TotalResponses of the AggregateFormResults object
object
-
questions(optional):
array questions
To Many Relationship to AggregateQuestionResult
array
-
Array of:
object instanceLink
Metadata describing link description objects that MAY appear in the JSON instance representation.
object
-
href:
string
URI [RFC3986] or URI Template [RFC6570]. If the value is set to URI Template, then the "templated" property must be set to true.
-
mediaType(optional):
string
Media type, as defined by RFC 2046, describing the link target.
-
method(optional):
string
HTTP method for requesting the target of the link.
-
profile(optional):
string
Link to the metadata of the resource, such as JSON-schema, that describes the resource expected when dereferencing the target resource..
-
rel:
string
Name of the link relation that, in addition to the type property, can be used to retrieve link details. For example, href or profile.
-
templated(optional):
boolean
Boolean flag that specifies that "href" property is a URI or URI Template. If the property is a URI template, set this value to true. By default, this value is false.
-
object
AggregateQuestionResultKey
Title:
AggregateQuestionResultKey
-
object
AggregateQuestionResultData-allOf[1]
object
AggregateQuestionResultKey
-
name(optional):
string
Localized display name for the Question
-
recordId(optional):
string
The unique record ID of the AggregateQuestionResult object.
-
referenceKey(optional):
string
The reference key for the AggregateQuestionResult object. AggregateQuestionResult objects support multiple languages. This field can be used to identify the associated objects for all languages.
object
-
averageResponse(optional):
number
AverageResponse of the AggregateQuestionResult object
-
totalResponses(optional):
integer
TotalResponses of the AggregateQuestionResult object
object
-
answers(optional):
array answers
To Many Relationship to AggregateAnswerResult
-
object
AggregateAnswerResultKey
Title:
AggregateAnswerResultKey
-
object
AggregateAnswerResult-allOf[1]
object
AggregateAnswerResultKey
-
name(optional):
string
Localized display name for the Answer
-
recordId(optional):
string
The unique record ID of the AggregateAnswerResult object.
-
referenceKey(optional):
string
The reference key for the AggregateAnswerResult object. AggregateAnswerResult objects support multiple languages. This field can be used to identify the associated objects for all languages.
object
-
totalResponses(optional):
integer
TotalResponses of the AggregateAnswerResult object
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 }