With POST requests data arrays to be read or written can be specified in the body of the HTTP request.
POST requests include the IP address, port number and plcpost
command in the URL. The payload must be specified in the HTTP body in JSON format.
For external calls: http://IP_OF_DEVICE:API_PORT/plcpost
Example: http://192.168.100.155:2000/plcpost
For internal calls when the code has been uploaded to the FP-I4C unit: plcpost
IP address of the FP-I4C unit
The API port set on the REST API/HTTP Server page
The payload must be structured as shown in the example.
Multiple requests: Read the integer values in DT0 to DT9, read a string starting from DT677, read the Boolean values of YF to Y18, write the integer values 1 to 10 to DT100 to DT109
{
"req":[
{
"area": "dt",
"type": "int",
"start": 0,
"count": 10
},
{
"area": "dt",
"type": "string",
"start": 677,
},
{
"area": "y",
"type": "bool",
"start": f,
"count": 10
},
{
"area": "dt",
"type": "int",
"start": 100,
"count": 10,
"value": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
},
],
"interface": 0,
"station": 0
}
Request list (array), max. 20 objects
COM interface of the PLC
Make sure the specified interface has been enabled on the COM Interface page and a port has been opened for this interface on the Port page.
If the parameter is omitted, the interface set under
will be used.Station number: 0 to 99 (use 0 for USB and RS232)
If the parameter is omitted, the station number set under
will be used.The request list "req" is an array of objects. Each object is a request on its own and may contain the following properties:
The data memory area. Valid areas (not case-sensitive):
DT, FL (for FP2/FP2SH and MEWTOCOL only), LD, WR, WX, WY, WL, R, X, Y, L
The data type. Valid data types (not case-sensitive):
INT, UINT, DINT, UDINT, REAL, STRING, ANY (read-only for registers, returns all data types except BOOL), BOOL
The start address of the register or flag. For registers, this must be a number. For Boolean flags, this must be a string.
The number of values to read or to write. This property is not needed for the STRING data type.
The value(s) to be written. This property is only used for write operations. If it is missing, a read operation is assumed. The value may be a single data type or an array. Make sure the value of the "count" property matches the number of values to write.
Examples:
The request list may contain different requests (read, write, different data types, etc.).
The data in the response is in the same order as in the request list.
To write Boolean values, use the keywords "true"/"false” or “1"/"0” (all without quotation marks).
The values of the "area" and "type" properties are not case-sensitive (e.g. “dt”, “Dt”, and “DT” will all work).
To read a string, you do not need to specify the "count" property.
The value of the "start" property must be a number for registers (DT, LD, WX, etc.) and a string for flags (R, Y, etc.)
To use the interface and station number set in the FP-I4C Web interface, omit the "interface" and "station" properties.
"req": The number of objects per request list is limited to 20.
"count": The maximum number of registers or flags that can be read or written is limited to 100.
The maximum string length that can be written is 1000 characters.
The response to a POST read request is a JSON string that contains error information and the requested data.
Each response contains the err, err_msg, and data property. The err property is TRUE if an error occurred and FALSE if no error occurred. The err_msg property contains the error message if the err property is TRUE or it is empty if the err property is FALSE. The data property is an array that contains the data in the same order as in the request.
{
"err": false,
"err_msg": "",
"data": []
}
The request list may contain different requests (read, write, different data types, etc.). However, the response format differs slightly depending on the type of request.
The data array of the response has the same length and order as in the request. For each object, the response contains the err, err_msg, and err_code property. The err property is TRUE if an error occurred and FALSE if no error occurred. The err_msg property contains the error message if the err property is TRUE, or it is empty if the err property is FALSE. The error code that is returned depends on the protocol used (MEWTOCOL, MEWTOCOL7, or Modbus). The request property contains the requested memory area and the start address. The data values are returned together with the data type either as an array (if more than one value was requested) or as a single value. For Boolean values, the state property returns the status (0 or 1) either as an array for a range of flags or as a single value.
Single request: Read the integer values in DT10 to DT19
{
"req":[
{
"area": "dt",
"type": "int",
"start": 10,
"count": 10
}
]
}
Response:
The response contains the requested array (data type "int” and count = 10). For count = 1, the response would be a single number.
{
"err": false,
"err_msg": "",
"data": [
{
"err": false,
"err_msg": "",
"err_code": 0,
"request": "DT10",
"int": [
20,
0,
0,
0,
0,
0,
0,
0,
0,
0,
]
}
]
}
Multiple requests: Read the string in DT673, read the values of any data type in DT100 to DT109, read the Boolean values in Y0 to Y15
{
"req":[
{
"area": "dt",
"type": "string",
"start": 673,
},
{
"area": "dt",
"type": "any",
"start": 100,
"count": 10
},
{
"area": "y",
"type": "bool",
"start": 0,
"count": 16
}
]
}
Response:
All data types except BOOL are returned for type = “any”.
{
"err": false,
"err_msg": "",
"data": [
{
"err": false,
"err_msg": "",
"err_code": 0,
"request": "DT673",
"string": "This is a string"
},
{
"err": false,
"err_msg": "",
"err_code": 0,
"request": "DT100",
"int": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
],
"uint": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
],
"udint": [
131073,
262147,
393221,
524295,
655369,
],
"dint": [
131073,
262147,
393221,
524295,
655369,
],
"hex": [
0001,
0002,
0003,
0004,
0005,
0006,
0007,
0008,
0009,
000A,
],
"real": [
5.969307950918661e-39,
6.061144848375116e-39,
6.152981745831572e-39,
6.244818643288028e-39,
6.336655540744483e-39,
],
"string": "",
"request": "DT100"
},
{
"err": false,
"err_msg": "",
"err_code": 0,
"request": "Y0",
"state": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
]
}
]
}
The response to a POST write request is a JSON string that contains error information.
Each response contains the err, err_msg, and data property. The err property is TRUE if an error occurred and FALSE if no error occurred. The err_msg property contains the error message if the err property is TRUE or it is empty if the err property is FALSE. The data property is an array that contains the data in the same order as in the request.
{
"err": false,
"err_msg": "",
"data": []
}
The request list may contain different requests (read, write, different data types, etc.). However, the response format differs slightly depending on the type of request.
The data array of the response has the same length and order as in the request. For each object, the response contains the err and the err_code property. The err property is TRUE if an error occurred and FALSE if no error occurred. The error code that is returned depends on the protocol used (Mewtocol, Mewtocol7, or Modbus). The request property contains the requested memory area and the start address.
Multiple requests: Write the integer values 22 and 33 in DT10 to DT11, set Y0 to TRUE and Y1 to FALSE, write the real value 22.88 to DT20
{
"req":[
{
"area": "dt",
"type": "int",
"start": 10,
"count": 2,
"value": [22, 33]
},
{
"area": "y",
"type": "bool",
"start": 0,
"count": 2,
"value": [1, false]
},
{
"area": "dt",
"type": "real",
"start": 20,
"count": 1,
"value": 22.88
}
]
}
Response:
The response does not contain any data values and only acknowledges success or failure of the write request.
{
"err": false,
"err_msg": "",
"data": [
{
"request": "DT10",
"err": false,
"err_code": 0,
},
{
"request": "Y0",
"err": false,
"err_code": 0,
},
{
"request": "DT20",
"err": false,
"err_code": 0,
}
]
}