API – Import external rating
- To import an external rating you need to send POST request to the following URI /api/rest.php/user-rating?action=set-external-user-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 'http://localhost:8080/api/rest.php/user-rating?action=set-external-user-rating' -H 'Authorization: Bearer xxxxxx' -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{"user_id":1189,"rating":94,"date":"2017-01-01"}'
Instead of a local address http://localhost:8080 you need to use the address of your server.
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 |
date* | String | Date in YYYY-MM-DD format |
Answer
- In case of successful request (HTTP code response - 200), it will be true
- In case of error (HTTP response code - 400) it returns JSON object with error information:
{"user_id":{"required":"Field cannot be empty"}}