Executing REST API calls using Siemens LHTTP library
In Siemens PLCs, we use the following REST APIs:
- POST /MinimalConfig
Synchronises locations and their categories. - POST /Interface/Watchdog
Monitors communication between the PLC and the Octalarm alarm dialler. - POST /Categories/Alarm
Activates or deactivates an alarm.
We use the Siemens LHTTP library to implement these HTTP POST requests. You can find the library and documentation on the Siemens support page, available for different TIA Portal versions.
Good to know: The tokens generated for each API connection are often longer than 256 characters. Therefore, we have modified the LHTTP_POSTPUT function block by increasing the UPPER_USER_FIELDS variable to 799. This customised version is referred to as LHTTP_POSTPUT_L in our code.
Note: ConnID must be unique for each instance.
- In our implementation, ConnID 1 is used for sending configuration and watchdog messages to the dialler, while ConnID 2 is used for transmitting the alarm status.
- If you intend to create additional connections in your PLC programme, always assign a unique ConnID for each connection to avoid conflicts.