Table of Contents
API – Import external rating
Use the API token for authorization. Read more in the article API token
Single import
- To import an external rating for sinle user you need to send POST request to the following URI /api/v2/users/external-rating/set-rating
- The request body should contain JSON object with information about user, date and rating value.
- The request must contain the headings Content-Type: application/json;charset=UTF-8 and Authorization: Bearer xxxxxx.
Request example:
curl 'https://your-domain.davintoo.com/api/v2/users/external-rating/set-rating' -H 'Authorization: Bearer xxxxxx' -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{"user_id":6085,"rating":94,"date":"2022-07-17"}'
Instead of a local address https://your-domain.davintoo.com you need to use the address of your instance.
In order for the external rating to be displayed on a graph in the user's learning history (in more detail Rating review by a user) the option must be enabled in the portal settings Allow adding external data to the user rating graph. This option is enabled by the technical support of the portal.
Format of the object with user information
* Mandatory fields are marked with an asterisk
To identify a user, either user_id or uid must be specified
Field | Type | Description |
---|---|---|
_userid | Number | Internal user ID in the system |
uid | String | External user ID in the system |
rating | Number | Value of external rating (single metric) |
complex_rating | Object | Value of external rating (object in format "field":"value") |
date* | String | Date in YYYY-MM-DD format |
Answer
- In case of successful request (HTTP code response - 200), it returns JSON object with update information
- In case of error (HTTP response code - 400) it returns JSON object with error information:
{"user_id":{"required":"Field cannot be empty"}}
Batch import
- To import an external rating for multiple users you need to send POST request to the following URI /api/v2/users/external-rating/set-ratings-multi
- The request body should contain array of JSON objects with information about user, date and rating value.
- The request must contain the headings Content-Type: application/json;charset=UTF-8 and Authorization: Bearer xxxxxx.
Request example:
curl 'https://your-domain.davintoo.com/api/v2/users/external-rating/set-ratings-multi' -H 'Authorization: Bearer xxxxxx' -H 'Content-Type: application/json;charset=UTF-8' --data-binary '[{"uid":"ux-123456","complex_rating":{"metric1":10,"metric2":20},"date":"2022-07-17"}]'