I'm trying to send an HTTPS POST request with a ESP8266. I can make the request just fine with python and cURL just when I try it with the ESP it doesn't work. A segment of my code is below
const char *host = "api.pushbullet.com";const int httpsPort = 443;const char fingerprint[] PROGMEM = "4C 70 C5 AE F3 30 E8 29 D1 9C 18 C6 2F 08 D0 6A A9 AA 19 0F";Link = "/post";httpsClient.print(String("POST ") + Link +" HTTP/1.1\r\n" +"Host: " + host +"/v2/pushes" +"\r\n" +"Access-Token: *************"+"\r\n" +"Content-Type: application/json"+"\r\n" +"Content-Length: 20"+"\r\n" +"body: Hello World" +"\r\n\r\n");Serial.println("request sent");The request I'm trying to make is below. This works just fine in python
import requestsheaders = {'Access-Token': '***********','Content-Type': 'application/json',}data = '{"body":"Hello World","title":"Hi","type":"note"}'response = requests.post('https://api.pushbullet.com/v2/pushes', headers=headers, data=data)And in cURL:
curl --header 'Access-Token: **********' --header 'Content-Type: application/json' --data-binary '{"body":"Hello World","title":"Hi","type":"note"}' --request POST https://api.pushbullet.com/v2/pushesWhen I make the request with the Arduino code it returns "Error 411 (Length Required)!!".
This is probably due to some stupid mistake I've made but if anyone could help me fix my Arduino code I'd be very grateful. Thanks