I am trying to use a SIM800 module on a TTgo-Tcall module to POST data to an API I have created on AWS api-gateway.
I can test the API independently using either postman or curl and I get the expected response.
When I make the POST from the TTgo module using the ArduinoHttpClient library, I get a 400 "Bad Request" error or 400 "The plain HTTP request was sent to HTTPS port" error.
This curl code works:-
curl --location --request POST 'https://38ywsfjpm3.execute-api.eu-west-1.amazonaws.com/v1/post-json' \
--header 'Content-Type: application/json' \
--data-raw '{"test":"apiinvoke"}'
This is what my Arduino code looks like:-
gprsClient.connectionKeepAlive();
SerialMon.println(" OK");
Serial.println("making POST request");
String contentType = "application/json";
String postData = "{\"test\":\"apiinvoke\"}";
String postString = "/v1/post-json HTTP/1.1\r\nHost: 38ywsfjpm3.execute-api.eu-west-1.amazonaws.com";
gprsClient.post(postString, contentType, postData);
// read the status code and body of the response
int statusCode = gprsClient.responseStatusCode();
String response = gprsClient.responseBody();
Serial.print("Status code: ");
Serial.println(statusCode);
Serial.print("Response: ");
Serial.println(response);
Can anyone spot what I am doing wrong?