- Mon Jun 24, 2019 10:18 am
#82920
I'm trying to call a logic app in azure but I can't seem to get the POST call quite right. I keep getting a timeout error -11 back. I think it probably has to do with how I'm sending the query string data. I can successfully call this endpoint using postman, but no luck using esp8266. Can anyone help me out? Here is my sketch:
Code: Select all#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <ArduinoJson.h>
const char* ssid = "";
const char* password = "";
void setup()
{
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(1000);
Serial.println("Connecting...");
}
}
void loop()
{
if (WiFi.status() == WL_CONNECTED)
{
HTTPClient http; //Object of class HTTPClient
http.begin("http://prod-16.northcentralus.logic.azure.com/workflows/f87d9b54a44f78ea24bc08/triggers/manual/paths/invoke");
//Add Headers
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
int httpCode = http.POST("api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=ZmTXX5SxkWI0vhbU");
if (httpCode > 0)
{
const size_t bufferSize = JSON_OBJECT_SIZE(2) + JSON_OBJECT_SIZE(3) + JSON_OBJECT_SIZE(5) + JSON_OBJECT_SIZE(8) + 370;
DynamicJsonDocument jsonBuffer(bufferSize);
DeserializationError error = deserializeJson(jsonBuffer, http.getString());
if (error)
return;
Serial.print(httpCode);
}
else
{
Serial.print(httpCode);
Serial.printf("[HTTP] ... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end(); //Close connection
}
delay(6000);
}