Skip to content

Instantly share code, notes, and snippets.

@kezzyhko
Created January 30, 2023 10:49
Show Gist options
  • Save kezzyhko/d4626ce8384d87dddb1464ff20e7b2e0 to your computer and use it in GitHub Desktop.
Save kezzyhko/d4626ce8384d87dddb1464ff20e7b2e0 to your computer and use it in GitHub Desktop.
Example of sending a custom event to devtodev
import requests
import zlib
from requests.structures import CaseInsensitiveDict
url = "https://api.devtodev.com/stat/v1/?api=KEY"
headers = CaseInsensitiveDict()
headers["Content-Type"] = "application/json"
data = r'{"2834420485":{"ce":[{"name":"TestEvent","entries":[{"p":{"t1":{"double":{"testDouble2":2.2,"testDouble1":1.1},"string":{"testOther2":"table: 0xccd0b9dfc6fb80ea","testString1":"A","testOther1":"Part","testString2":"B","testString3":"C"},"boolean":{"testBool1":true}}},"t1":1674753603}]}]}}'
headers['content-encoding'] = 'gzip'
data = zlib.compress(data.encode('utf-8'))
resp = requests.post(url, headers=headers, data=data)
print(resp.status_code, resp.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment