Hi,
I want to POST a question to Vägverket API, but I can not figure out to write the request
http://api.trafikinfo.trafikverket.se/Console
The request shall be
Deviation.Id
Deviation.Header
Deviation.IconId
Deviation.Geometry.WGS84
and the URL http://api.trafikinfo.trafikverket.se/v1.3/data.json
I used a simple code, but I realise that I am not even able to get the " sign of the request in the string to be used in http.POST("XXXX")
Can any one please guide me to how shall this be written??
#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>
const char* ssid = "xxx";
const char* password = "yyy";
void setup() {
Serial.begin(115200); //Serial connection
WiFi.begin(ssid, password); //WiFi connection
while (WiFi.status() != WL_CONNECTED) { //Wait for the WiFI connection completion
delay(500);
Serial.println("Waiting for connection");
}
}
void loop() {
if(WiFi.status()== WL_CONNECTED){ //Check WiFi connection status
HTTPClient http; //Declare object of class HTTPClient
http.begin("http://api.trafikinfo.trafikverket.se/v1.3/data.json"); //Specify request destination
http.addHeader("Content-Type", "text/plain"); //Specify content-type header
int httpCode = http.POST("XXXX"); //Send the request
String payload = http.getString(); //Get the response payload
Serial.println(httpCode); //Print HTTP return code
Serial.println(payload); //Print request response payload
http.end(); //Close connection
}else{
Serial.println("Error in WiFi connection");
}
delay(30000); //Send a request every 30 seconds
}