I’m trying to replicate the functionality of the attached payload subscribe.py file using ignition.
Payload Subscribe.py (2.5 KB)
I create a button in vision to replicate the subscription to web events. It calls this function:
def subToWebEvent():
# Post data to the web service in JSON format.
# This allows you to use the 'data' object in the Python Resource.
projectName = "MyProject"
folderName = "testServer"
doPostName = "postjson"
my_ip_address = "192.168.20.209"
fleet_ip = "192.168.20.110"
fleet_authentication = "mir_GjX6dSiBJCrWCGDY1QTVeQUNpv93Yp5Sv5Ya9HqUL1oOgKlyvHhgpYM6PeOGVpxRNwYf2I"
my_ip_and_port = my_ip_address + ":8090"
# SUBSCRIBE AGAIN
HEADERS = {
'accept': 'application/json',
'x-api-key': fleet_authentication,
'Content-Type': 'application/json'
}
params = {
"base-url": "http://" + my_ip_and_port+"/system/webdev/samplequickstart/Test",
"endpoints": [
{
"event-type": "Subscription",
"endpoint-paths": [
"/WebhookTest"
]
},
{
"event-type": "Payload",
"endpoint-paths": [
"/WebhookTest"
]
}
]
}
jsonParams = system.util.jsonEncode(params)
print(jsonParams)
client = system.net.httpClient()
response = client.post(
'http://192.168.20.110/api/v1/subscription',
headers=HEADERS,
data=jsonParams
)
print("POSTED")
Then I added a folder in web Dev containing a webhook test doPost handler:
doPost.py (82 Bytes)
I can see in Wireshark that the POSTs from the MiR webhook are getting rejected with error 405. I replicated the payload using postman to insure the webhook test address was correct and it handled the payload correctly. What have I done wrong?