LMS Collaborator knowledge base

Home/Technical requirements/API/API - Notices

API – Notices

Creating notices #

See API–Authorization

  • 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:
    user_id - Id of the user
    checked - true
  • 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:
    data - empty array
    users_of_task - total number of users assigned to the notice
  • In case of error (HTTP response code - 400) it returns JSON object with information about the error

List of notices for the user #

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:
    data - user tasks array
    pager - pagination object (information about the number of pages, the current page, the number of tasks)
    counts - counter object (information about the number of tasks grouped by statuses)
  • In case of error (HTTP response code - 400) it returns JSON object with error information
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