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

Материал из WebHMI Wiki
Перейти к: навигация, поиск
(Новая страница: «Headers: <pre> Accept: application/json Content-Type: application/json Accept-Encoding: gzip, deflate, sdch X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7…»)
(Новая страница: «Query body: <pre> {"value":"15"} </pre>»)
Строка 34: Строка 34:
 
</pre>
 
</pre>
  
Тело запроса:
+
Query body:
 
<pre>
 
<pre>
 
{"value":"15"}
 
{"value":"15"}

Версия 10:44, 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

Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.

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

In the body of the request, you must pass a json object with a single property "value":

{"value":"12"}


Example of writing a value of 15 to the register c ID = 5:

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

Headers:

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

Query body:

{"value":"15"}

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