API – Notices
Creating notices #
- To create an ad you need to send a POST request to the following URL /api/rest.php/notices
- The body of the request must contain a JSON object with information about the notice.
- 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/notices' -H 'Authorization: Bearer xxxxxx' -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{"type": "simple", "title":"Test", "description":"body", "is_published":"1"}'
Format of the object with user information
*Mandatory fields are marked with an asterisk
Field | Type | Description |
---|---|---|
type* | String | Notice type(there are three types: simple, free, required) |
title* | String | Notice title |
description* | String | Text |
is_published | Number | Check mark, 1 - announcement is published, 0 - news is NOT published |
date_begin | String | Publication date |
date_end | String | Completion date |
Answer
- In case of successful request (HTTP response code - 200), there will be a JSON response with information about the created notice:
{"data":{"id":105,"type": "simple", "title":"Test", "description":"body", "is_published":1...}
- In case of error (HTTP response code - 400) it returns JSON object with error information:
{"title":{"required":"Field cannot be empty"}}
Assigning notices to users #
- To assign a task to a user, you need to send a POST request to the following URL http://localhost:8080/api/rest.php/notices/{noticeId}?action=assign
- The request string must contain {noticeId} Id of the notice. The body of the request must contain a JSON object with the following fields:
- Id of the useruser_id
- truechecked
- The query must contain the headings Content-Type: application/json;charset=UTF-8 and Authorization: Bearer xxxxxx. Request example:
curl 'http://localhost:8080/api/rest.php/notices/123456?action=assign' -H 'Authorization: Bearer xxxxxx' -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{"user_id":987654, "checked":true}'
Answer
- In case of successful request (HTTP response code - 200), the following result will be returned:
- empty arraydata
- total number of users assigned to the noticeusers_of_task
- In case of error (HTTP response code - 400) it returns JSON object with information about the error
List of notices for the user #
- To get the list of tasks assigned to a user you need to send GET request to the following URI http://localhost:8080/api/rest.php/tasks?page=1&count=10&filter[data_filter]=new&action=my&uid={uid}
- The request must contain {uid} ("External No.") of the user.
- The request must contain the headings Content-Type: application/json;charset=UTF-8 и Authorization: Bearer xxxxxx.
Request example:
curl 'http://localhost:8080/api/rest.php/tasks?page=1&count=10&filter[data_filter]=new&action=my&uid=123' -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:
- user tasks 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