Get aggregate rating result
/km/api/v1/content/{id}/ratingsAggregate
This method returns the AggregateFormResults object that represents all the rating responses for the specified Content translation. The AggregateFormResults object includes the rating's questions and rating's 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 Engagement Cloud Knowledge REST APIs. 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 userToken attribute on the kmauthtoken header is created for the logged-in user. Additionally, the Locale can be specified by the langpref request parameter.
The method sums the response for each question and calculates the average rating for the Content object based on the ratings type for the specified Locale. Rating types other than the Five-Star rating have zero as the value of the average rating.
There are three types of ratings:
- Five-Star rating ??? A row of five star icons appear at the end of the article. Each star icon represents the level of quality.
- Like and dislike - Thumbs-up symbol represents like and thumbs-down symbol represents dislike.
- No ratings
Note: A Content object can be rated only for a specific Locale. Therefore, 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
This error occurs when an invalid ID is specified in the request.
- OKDOM-SURV0018
This error occurs when rating type is configured as no rating.
Request
-
id: string
The content identifier.
Response
- application/json
- application/xml
200 Response
object
AggregateFormResults
-
links(optional):
array links
-
questions(optional):
array questions
To Many Relationship to AggregateQuestionResult
-
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.
-
totalResponses(optional):
integer
TotalResponses of the AggregateFormResults object
array
-
Array of:
object instanceLink
Metadata describing link description objects that MAY appear in the JSON instance representation.
array
-
Array of:
object AggregateQuestionResult
Title:
AggregateQuestionResult
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
AggregateQuestionResult
-
answers(optional):
array answers
To Many Relationship to AggregateAnswerResult
-
averageResponse(optional):
number
AverageResponse of the AggregateQuestionResult object
-
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.
-
totalResponses(optional):
integer
TotalResponses of the AggregateQuestionResult object
array
-
Array of:
object AggregateAnswerResult
Title:
AggregateAnswerResult
object
AggregateAnswerResult
-
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.
-
totalResponses(optional):
integer
TotalResponses of the AggregateAnswerResult object
Examples
Example 1
The following example show how to find the aggregate questions and answers of a rating for the specified Content object when the rating type is Five-Star.
curl -X GET "https://<IM_REST_API_HOST>/km/api/latest/content/{id}/ratingsAggregate" -u "<username:password>" -H "Accept: application/json" -H "Content-Type: application/json"
Example of Response Body
The following example shows the contents of the response body in JSON format:
{ "questions": [ { "answers": [ { "totalResponses": 2, "recordId": "29C9EEA5CB2B484A94762A4B1517EB57", "referenceKey": "A5", "name": "5" }, { "totalResponses": 1, "recordId": "3A9A0952D3CF4A138FA4518A0F25F020", "referenceKey": "A3", "name": "3" }, { "totalResponses": 0, "recordId": "4EFDA9A45A144CFDA9E0973A04BD5114", "referenceKey": "A2", "name": "2" }, { "totalResponses": 1, "recordId": "6BF001ED4CEB4EF1A007355BEE421F46", "referenceKey": "A4", "name": "4" }, { "totalResponses": 0, "recordId": "FC0EBC5507A041029D0FFE62A7DEAA6A", "referenceKey": "A1", "name": "1" } ], "recordId": "D56585C3385846B5A8D700593E1C96F4", "referenceKey": "Q1", "name": "How would you rate this document?", "totalResponses": 4, "averageResponse": 4.25 } ], "recordId": "EBA5CB446E25451C994D881F60FDA0BD", "referenceKey": "5_STAR_RATING", "links": [ { "rel": "canonical", "href": "https://<IM_REST_API_HOST>/km/api/latest/content/<content ID>/ratingsAggregate", "mediaType": "application/json, application/xml", "method": "GET" } ], "totalResponses": 4 }
Example 2
The following example shows how to find the aggregate questions and answers of a rating for the specified Content object when the rating type is like and dislike.
curl -X GET "https://<IM_REST_API_HOST>/km/api/latest/content/{id}/ratingsAggregate" -u "<username:password>" -H "Accept: application/json" -H "Content-Type: application/json"
Example of Response Body
The following example shows the contents of the response body in JSON format:
{ "questions": [ { "answers": [ { "totalResponses": 2, "recordId": "874CF739B99F4D358050B6C5CCC819F6", "referenceKey": "YES_OR_NO_RATING_A1", "name": "Dislike" }, { "totalResponses": 1, "recordId": "B73836830DC0401FA931120E4634408A", "referenceKey": "YES_OR_NO_RATING_A2", "name": "Like" } ], "recordId": "94AEF5ABE53A4E609EFD0A208E9007C3", "referenceKey": "YES_OR_NO_RATING_Q1", "name": "Do you like this Article?", "totalResponses": 3, "averageResponse": 0 } ], "recordId": "45C98B085B044881821DE07F68DC14CF", "referenceKey": "YES_OR_NO_RATING", "links": [ { "rel": "canonical", "href": "https://<IM_REST_API_HOST>/km/api/latest/content/<content ID>/ratingsAggregate", "mediaType": "application/json, application/xml", "method": "GET" } ], "totalResponses": 3 }