@David4 ,
Like @CodeShepherd said, you need a client that supports SSE. Python requests does not. See sseclient-py as an example.
Here is a modification of your code above.
# Make the POST request
motion_info = requests.post(url, json=payload, headers=head, verify=False)
# Check the response for the POST request
if motion_info.status_code == 201:
response_data = motion_info.json # Call the method to get JSON data
print(response_data) # Print the response data
else:
print(f"Error: {motion_info.status_code} - {motion_info.text}")
url = "https://10.0.2.2:8443/automation/api/v2/events/subID"
stream_response = requests.get(url, headers=head, verify=False, stream=True)
client = sseclient.SSEClient(stream_response)
# Loop forever (while connection "open")
for event in client.events():
print ("got a new event from server")
pprint.pprint(event.data)
... View more