API – News
API - News list
- To get the list of news created on the portal you need to send GET request to the URI https://your-domain.davintoo.com/api/rest.php/news?action=get-all-public-news
- The request must contain the following headings Content-Type: application/json;charset=UTF-8 и Authorization: Bearer xxxxxx.
Request example:
curl 'https://your-domain.davintoo.com/api/rest.php/news?action=get-all-public-news' -H 'Authorization: Bearer xxxxxx' -H 'Content-Type: application/json;charset=UTF-8'
Answer
-
In case of successful request (HTTP response code - 200), the following result will be returned:
- news arraydata
- pagination object (information about the number of pages, the current page, the number of news)pager
-
In case of error (HTTP response code - 400) it returns JSON object with error information
API - Adding news
- To create news you need to send POST request to URI /api/v2/news/create
- The request body must contain a JSON object with information about the news.
- The request must contain the following headings Content-Type: application/json;charset=UTF-8 и Authorization: Bearer xxxxxx.
Request example:
curl 'https://your-domain.davintoo.com/api/v2/news/create' -H 'Authorization: Bearer xxxxxx' -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{"public_at": "2022-07-20", "actual_to": "2022-07-25", "is_published": "true", "title":"How to choose an LMS for corporate training: criteria and tips", "body_text":"Implementing an LMS helps get rid of routine and automate many processes, such as standardizing training, onboarding, and certification. Choosing the right LMS is not an easy process, requiring time and a clear plan of goals and objectives.In this article we will tell you what to look for and what you need to consider when choosing a system for corporate training."}'
Format of the object with information about the news
* Required fields are marked with an asterisk
Field | Type | Description |
---|---|---|
title* | Line | News title |
_bodytext* | Line | Text |
is_published | Number | Flag, 1 - news published, 0 - the news is NOT published |
publicat* | Line | Publication date |
Answer
- In case of successful request (HTTP response code - 200), there will be reply in JSON format with information about created news:
{"data":{"id":105,"title":"title","body_text":"body","is_published":true...}
-In case of error (HTTP response code - 400) it returns JSON object with error information:
{"title":{"required":"Field cannot be empty"}}