Hello, I am trying to send collected data formatted as json to an API hosted on Azure.
This is the code I use
GSMClient client;
char url[] = "my-azure.northeurope.cloudapp.azure.com";
char path[] = "/api/store";
void parseData(String dataToSend)
{
if (client.connect(url, 80))
{
client.println("POST http://my-azure.northeurope.cloudapp.azure.com/api/store HTTP/1.0");
client.println("Content-Type: application/json");
client.println("User-Agent: Arduino/1.0");
client.println("Connection: close");
client.print("Content-Length: ");
client.println(dataToSend.length());
client.println("");
client.println(dataToSend);
}
else
{
...
}
}
The result:
Msg from http
HTTP/1.0 302 Found
Date: Thu, 27 Jan 2022 22:13:09 GMT
Server: Apache/2.4.41 (Ubuntu)
Cache-Control: private, must-revalidate
Location: http://my-azure.northeurope.cloudapp.azure.com
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 59
pragma: no-cache
expires: -1
Vary: Origin
Content-Length: 446
Connection: close
Content-Type: text/html; charset=UTF-8
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="refresh" content="0;url='http://my-azure.northeurope.cloudapp.azure.com'" />
<title>Redirecting to http://my-azure.northeurope.cloudapp.azure.com</title>
</head>
<body>
Redirecting to <a href="http://my-azure.northeurope.cloudapp.azure.com">http://my-azure.northeurope.cloudapp.azure.com</a>.
</body>
</html>
However if I try the same post in Postman or use a url of an API not hosted on Azure it works... Anyone has an idea?
Thank alot!