LMS Collaborator knowledge base

Home/Technical requirements/API/API - News

API – News

API - News list

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:
    data - news array
    pager - pagination object (information about the number of pages, the current page, the number of news)

  • 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"}}
Still have questions?
Our technical support team is always happy to help!
Write to us at technical support [email protected]. If you are registered on our Helpdesk - send request button below.
Send request