HTTP post function

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
poduris
Posts: 5
Joined: Wed Oct 05, 2016 1:59 pm

HTTP post function

Post by poduris » Sun Oct 09, 2016 4:11 am

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 ?

chrisgp
Posts: 41
Joined: Fri Apr 01, 2016 5:29 pm

Re: HTTP post function

Post by chrisgp » Sun Oct 09, 2016 4:36 am

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.

poduris
Posts: 5
Joined: Wed Oct 05, 2016 1:59 pm

Re: HTTP post function

Post by poduris » Sun Oct 09, 2016 5:37 pm

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.

chrisgp
Posts: 41
Joined: Fri Apr 01, 2016 5:29 pm

Re: HTTP post function

Post by chrisgp » Sun Oct 09, 2016 7:40 pm

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.

Post Reply