Python scripts can be exposed as HTTP endpoints. See the Postman workspace at https://www.postman.com/envisionscada/envisionscada-workspace/collection/c8etupk/envisionscada-api?action=share&creator=17987048 for a SetTemperature example. Assign an Endpoint to a Python script as shown below.
In the POST request, configure the user/password as Basic Auth. This must be a configured user inside EnvisionSCADA, and this user must belong to a group that has the rights to execute this script.
Construct the request body as needed. A small example:
Now inside the PythonScript, you can get the Body like the example below. What is printed using Print, will be returned as response. When the script runs outside an API call (for example when you test it in the Python Editor), GetParam returns the default value you pass, so provide a sensible default (such as an empty JSON object) as the second argument.
import json
data = json.loads(GetParam("body", "{}"))
temperature = data.get("temperature", 0)
SetValue("PLC.Temperature", str(temperature))
print("Done")Resulting in: