How to get xml response raw data
RanchaIET opened this issue · 1 comments
RanchaIET commented
following code working properly. i want to catch xml response.
#include <ArduinoHttpClient.h>
#include <SPI.h>
#include <UIPEthernet.h> //ENC28J60 eth
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char serverAddress[] = "71.94.216.26"; //public server address
int port = 80;
int statusCode = 0;
String response;
boolean goloop = 1;
IPAddress ip(192, 168, 1, 177);
EthernetClient eth;
HttpClient client = HttpClient(eth, serverAddress, port);
void setup() {
Serial.begin(9600);
while (!Serial) {
;
}
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
Ethernet.begin(mac, ip);
}
delay(1000);
Serial.println("connecting...");
}
void loop() {
while(goloop){
Serial.println("making POST request");
String postData = "<TSA_REQUEST_LIST><TSA_REQUEST COMMAND=\"cmdAppGetFMSTankStatus\"/></TSA_REQUEST_LIST>";
// String postData = "<TSA_REQUEST_LIST PASSWORD=\"\"><TSA_REQUEST COMMAND=\"cmdAppGetFMSTankStatus\"/></TSA_REQUEST_LIST>";
client.beginRequest();
client.post("/cgi-bin/tsaws.cgi");
client.sendHeader("Content-Type", "text/xml");
client.sendHeader("Content-Length", 84);
client.beginBody();
client.print(postData);
statusCode = client.responseStatusCode();
response = client.responseBody();
Serial.println("Wait five seconds");
delay(5000);
if(statusCode == 200){
goloop = 0;
}
}
///////////////////////
// statusCode = client.responseStatusCode();
response = client.responseBody();
Serial.print("Status code2: ");
Serial.println(statusCode);
Serial.print("Response2: ");
Serial.println(response);
Serial.println("Wait one seconds");
delay(1000);
}per1234 commented
Hi @RanchaIET. Thanks for your interest in this open source project. This issue tracker is only to be used to report bugs or feature requests specific to the project. This topic is more appropriate for the Arduino Forum. I'm sure we will be able to help you out over there: