Created
April 24, 2023 13:52
-
-
Save ejohnso49/c367ade9161d7d7d00085bd5c00250a5 to your computer and use it in GitHub Desktop.
Events Endpoint Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import requests | |
url = "https://ingress.memfault.com/api/v0/events" | |
payload = json.dumps( | |
[ | |
{ | |
"type": "heartbeat", | |
"software_type": "zephyr-app", # Designate type for different device components (mcu, modem, etc) | |
"software_version": "1.0.0+cfacefbcb", # Device's software version | |
"device_serial": "UI_TESTSERIAL", | |
"hardware_version": "qemu_cortex_m3", | |
"sdk_version": "0.43.0", # Should match the version on your devices, if unknown use >= 0.5.0 | |
"event_info": { | |
"metrics": { | |
"battery_pct": 15, # Ints or floats valid | |
"location": "41.8781N,87.6298W", # Strings are valid | |
} | |
}, | |
"user_info": {"whatever": "you_want"}, | |
} | |
] | |
) | |
headers = { | |
"Content-Type": "application/json", | |
"Memfault-Project-Key": "<YOUR_PROJECT_KEY>", | |
} | |
response = requests.request("POST", url, headers=headers, data=payload) | |
print(response.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment