I am trying to grab weather data from my TFA weather station via Rest API. The corresponding API documentation can be found here: https://mobile-alerts.eu/info/public_server_api_documentation.pdf
The following code results in a 400 response with "Request parameters invalid"
import requests
from urllib.parse import urlencode
url = 'https://www.data199.com/api/pv1/device/lastmeasurement'
device_id = 'XXX'
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
params = {'deviceids': device_id}
# first try
res = requests.post(url, params=params, headers = headers)
print(res.text)
# second try
params_encoded = urlencode(params)
res = requests.post(url + '?' + params_encoded)
print(res.text)
Of course, the device_id is not 'XXX' but a correct ID of one of my devices. Am I missing something obvious?