Page 1 of 1

HTTP post function

Posted: Sun Oct 09, 2016 4:11 am
by poduris
Hi All,

In the ESP8266 micropython documentation http get function is mentioned, however I want http post function to upload sensor values through thingspeak api. how can I do it ?

Re: HTTP post function

Posted: Sun Oct 09, 2016 4:36 am
by chrisgp
Try out this urequests library: https://github.com/micropython/micropyt ... equests.py. It supports POST requests and should allow you to specify anything else you might need for headers and such.

Re: HTTP post function

Posted: Sun Oct 09, 2016 5:37 pm
by poduris
Thanks Chris !

Where in the Code I need to mention API key.. ? I'm getting response codes but unable to put/post data as I'm not sure where to include API keys.

Re: HTTP post function

Posted: Sun Oct 09, 2016 7:40 pm
by chrisgp
I'm not familiar with the Thingspeak API but they probably want to you specify it as a header. You would accomplish this by adding a argument to your call to POST, like headers={"API-KEY":"MyAPIKey"}, assuming the name of the header they want is API-KEY and the value of your API Key is MyAPIKey. You'll have to check their docs to see how they expect the key to be supplied.