I am using an esp32 and the ArduinoHttpClient to communicate with JPL's Horizons API in order to get some planetary ephemeris. The problem is whenever I attempt to preform a get request I get a status code of -2 (I know that a -2 response is a "HTTPC_ERROR_SEND_HEADER_FAILED" error but I am not sure what that refers too) and nothing in the response body. The HttpClient works with the other API requests I perform, it's just when I try to do one with the horizons API.
WiFiClient wifi;
char ipifyAddress[] = "api.ipify.org"; // server address
char ipStackAddress[] = "api.ipstack.com"; // server address
char horizonsAddress[] = "ssd.jpl.nasa.gov";
int port = 80;
HttpClient client = HttpClient(wifi, ipifyAddress, port);
HttpClient locationClient = HttpClient(wifi, ipStackAddress, port);
HttpClient horizonsClient = HttpClient(wifi, horizonsAddress, port);
void horizons(double* longLat, String* day){
String cTCheck = "/api/horizons.api?format=text&COMMAND='499'";
horizonsClient.get(cTCheck);
int statusCode = horizonsClient.responseStatusCode();
String response = horizonsClient.responseBody();
Serial.println(horizonsClient.contentLength());
Serial.print("Status code: ");
Serial.println(statusCode);
Serial.print("Response: ");
Serial.println(response);
horizonsClient.stop();
}
I have attempted to modify the address I perform the get request from including just "/api/horizons.api", which should return a "lack of commands" return from the API but even that still returns a -2.
I also used the .stop() function with the other httpClients once their tasks are complete so I doubt the other functions are causing a problem. I also tried escaping the single quotes but that doesnt make a different either.
Thanks.
