0

我们正在尝试从 ESP8266 向 aws 云发出 HTTPS POST 请求,但无法与服务器通信。代码片段如下:

WiFiClientSecure client;
char data[100];
DynamicJsonBuffer jsonBuffer;
char host[] = "test.execute-api.us-east-1.amazonaws.com";
if (client.connect(host, 443)) {
   String URL = "/dev";
   JsonObject& root = jsonBuffer.createObject();
   root["Id"] = 105132;
   sprintf(data, "{\"Id\":105132}");
   client.println("POST " + URL+ " HTTP/1.1");
   client.print("Host: " + (String)host);  
   client.println("User-Agent: arduino/1.0");
   client.println(data);
   client.println("Content-Type: application/json");
}

工作邮递员要求如下:

URL : https://test.execute-api.us-east-1.amazonaws.com/dev 
Header : Content-Type : application/json
Body : {"Id" : 105132 }
4

0 回答 0