Table of Contents
API – News
API - News list #
- To get the list of tasks assigned to a user you need to send GET request to the URI http://localhost:8080/api/rest.php/news?page=1&count=10&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 'http://localhost:8080/api/rest.php/news?page=1&count=10&action=get-all-public-news' -H 'Authorization: Bearer xxxxxx' -H 'Content-Type: application/json;charset=UTF-8'
Instead of a local address http://localhost:8080 you need to use the address of your server.
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 tasks)pager
- counter object (information about the number of tasks grouped by statuses)counts
- 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/rest.php/news
- 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 'http://localhost:8080/api/rest.php/news' -H 'Authorization: Bearer xxxxxx' -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{"title":"1", "body_text":"body"}'
Instead of a local address http://localhost:8080 you need to use the address of your server.
Format of the object with information about the user
* 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"}}