I have a Webservice wich is reachable over a URL and I have a Raspberry with different sensors wich measures the temperature and co2.Now I want to write a Python script to send this values to the Webserver.


2 Answers 2


Take a look at python-requests API. It's readily available as a dpkg package on raspberry pi's repos. http://docs.python-requests.org/en/master/


Assuming your web service is expecting a GET request with data passed as query string parameters, you would do something like this:

import requests
payload = {'sensor': 'temp1', 'temperature': 32}
response = requests.get('https://server.example.com/webservice/endpoint', params=payload)

Similar with a POST request to an endpoint expecting JSON encoded data:

response = requests.post('https://server.example.com/webservice/endpoint2', json=payload)

Tell us more about the webservice and I will edit the answer accordingly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.