Connect to custom API

Is it possible to send data to custom server?

For example “api.myserver.com”, port 80

client.connect(“api.myserver.com”, 80);
client.println(“GET /api.php?data=dev:XX;rt:XX;h:XX;t:XX; HTTP/1.1”);

Thanks

Any help? Is there any documentation for this?

Hi @sanwin

I think that what you want to do should be easy. Here is some code that I use. You may have to % escape the XX fields in the URL.

void sendGetRequest(const char * server, const char * url)
{
    if (myTCP.connect(server, 80)) {
        //Serial1.print("Connected to Server");
        digitalWrite(D7,HIGH);
        myTCP.print("GET ");
        myTCP.print(url);
        myTCP.println(" HTTP/1.0");
        myTCP.println("Connection: close");
        myTCP.print("Host: ");
        myTCP.println(server);
        myTCP.println("Accept: text/html, text/plain");
        myTCP.println();
        myTCP.flush();
    } 
}
1 Like

Thanks, working now!

1 Like