Requests
The requests are available in both protocols (HTTP & JSON TCP).
HTTP
The requests operate according to the definitions of the HTTP protocol and accept the GET and POST methods. Parameters are to be passed in the data of these methods.
The requests return a JSON file (except for Get Files
requests). If the request has no error, the JSON file will contain a variable code
with the value 200
. If an error is detected, the code
variable will have the value 400
. An array named message
will also be returned, containing error messages.
Error response exemple :
{
"code":400,
"message":[
"The received JSON cannot be parsed"
]
}
JSON TCP
The JSON TCP protocol also accepts requests. For this, a JSON must be sent with an object variable named request
containing the following variables:
url
Endpoint of the request.
- Type:
string
data
Request parameters.
- Type:
Array
of
json-tcp-parameter-array
- Note: The JSON data must be stringified
Request exemple :
{
"request": {
"url":"/api/set/json",
"data":[
["json":"{...}"]
]
},
"id":"message-id", //Optional
"password":"password" //If defined and only for the first request
}
Response exemple :
{
"request":{
"response": {
"code":200
},
"content_type":"application/json"
},
"id":"message-id" //Returns the received ID if defined.
}
Error Response :
In case of an error, the server returns an object named error
:
{
"error":{
"code": 401,
"desc":"Unauthorized"
},
"id":"message-id" //Returns the received ID if defined.
}
- code:
Error code similar to HTTP error codes
- desc:
Description of the error