API - Запись нового значения в регистр/en — различия между версиями

Материал из WebHMI Wiki
Перейти к: навигация, поиск
(Новая страница: «To write a new value to the register, it is necessary to execute the PUT request for a URL of the form '' 'http://192.168.1.1/api/register-values/23' ''. Here 23…»)
(Новая страница: «In the request headers, you must pass the API key. For example: <pre> X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7 </pre>»)
Строка 1: Строка 1:
 
To write a new value to the register, it is necessary to execute the PUT request for a URL of the form '' 'http://192.168.1.1/api/register-values/23' ''. Here 23 is the register ID for which you want to change the value.
 
To write a new value to the register, it is necessary to execute the PUT request for a URL of the form '' 'http://192.168.1.1/api/register-values/23' ''. Here 23 is the register ID for which you want to change the value.
  
В заголовках запроса необходимо передать API key. Например:
+
In the request headers, you must pass the API key. For example:
 
<pre>
 
<pre>
 
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7
 
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Версия 10:43, 13 апреля 2018

To write a new value to the register, it is necessary to execute the PUT request for a URL of the form 'http://192.168.1.1/api/register-values/23' . Here 23 is the register ID for which you want to change the value.

In the request headers, you must pass the API key. For example:

X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Также в заголовках необходимо указать желаемый формат обмена данными. Сейчас поддерживатеся работа только с форматом JSON.

Accept: application/json
Content-Type: application/json

В теле запроса необходимо передать json-объект с единственным свойством "value":

{"value":"12"}


Пример записи значения 15 в регистр c ID = 5:

URL: http://192.168.1.1/api/register-values/5
Method: PUT

Заголовки:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Тело запроса:

{"value":"15"}

Если запрос валидный то API вернет HTTP-код 200.