MKR Zero trying to use a google script but can not get the url to execute

Hardware i am using:
MKR ETH
MKR ZERO
MKR THERM

Problem, I can not get my code to execute a google script call to log data.

What i want to do: Take thermocouple data and store it to a google sheet. Right now i am just trying to get the URL for the google script to work. It does not appear to be “GETing”

Some requirements:
I do not want to use any third part services, or hooks, or anything like that.
I do not really want to use other hardware, I like the compactness of the MKR equipment and I like the thermocouple shield, this is an industrial application, i do not want to use wifi because it is not reliable.
I am masking the script URL "STUFF"for security concerns.
I might need to switch to a YUN, i think my problem is the library needs linux from the yun, but i hope i am wrong or there is a workaround.

What i know:
I Know my google script works, i can get it to work by pasting the url into a browser and the spreadsheet changes values
I know that my URL in the MKR is correct because i can paste that in a browser and it executes.
I am fairly certain the MKR is connected to my LAN, I can get an IP address. and i used some other example codes that seem to execute google searches.

What i have tried:
I tried modifying this, and cant seem to get it to go to my script url

I got the idea for all of this from the post here

CODE:

#include <SPI.h>
#include <Ethernet.h>
#include <HttpClient.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = {  
  0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

void setup() {
  // start the serial library:
  Serial.begin(9600);
  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
 
  }
  // print your local IP address:
  Serial.println(Ethernet.localIP());

    const String logURL = "https://script.google.com/macros/s/STUFF";
    HttpClient client;
    client.noCheckSSL();  //required because the web app URL is https://...
    String URL;
    URL += logURL;
    URL += "?Key1=";   //"Key1" must match a column name in your spreadsheet
    URL += "value1";     //"value1" can be whatever data from your sketch you want to log
    URL += "&Key2=";   //"Key2" must match a column name in your spreadsheet
    URL += "value2";     //"value2" can be whatever data from your sketch you want to log
                       //you can add as many key/value pairs as you need to...
    client.get(URL);
    Serial.println(URL);


}

void loop() {

}

Gonna try bumping this, as maybee someone know something

Try reading from the connection to see if you get some kind of error from the server.

Try putting this in loop():

  if (client.available())
    Serial.write(client.read());

it does not do anything

My mistake. You have two variables named 'client'. The global EthernetClient isn't used. The HttpClient that is used is local to the setup() function. It might work if you comment out the global "EthernetClient client;" and move the "HttpClient client;" out of setup() so it is global.

Does HttpClient::get() return a value? If it does, that also might be a good thing to print out:

    Serial.println(URL);
    Serial.print(F("Returned value: ");
    Serial.println(client.get(URL));

EDIT: Replied to hastily

I am attempting this, i got 256, but the code was wrong, i will reply back soon

johnwasser:
My mistake. You have two variables named ‘client’. The global EthernetClient isn’t used. The HttpClient that is used is local to the setup() function. It might work if you comment out the global “EthernetClient client;” and move the “HttpClient client;” out of setup() so it is global.

Does HttpClient::get() return a value? If it does, that also might be a good thing to print out:

    Serial.println(URL);

Serial.print(F("Returned value: ");
    Serial.println(client.get(URL));

Returned value: 18943

when i made the variable global i get 53759

#include <SPI.h>
#include <Ethernet.h>
#include <HttpClient.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 
  0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
//EthernetClient client;

void setup() {
  // start the serial library:
  Serial.begin(9600);
  delay(2000);
  Serial.println("serial intialized");
  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
 
  }
  // print your local IP address:
  Serial.println(Ethernet.localIP());

    const String logURL = "https://script.google.com/macros/s/private";
    Serial.println("http client");
    HttpClient client;
    client.noCheckSSL();  //required because the web app URL is https://...
    String URL;
    URL += logURL;
    URL += "?Key1=";   //"Key1" must match a column name in your spreadsheet
    URL += "value1";     //"value1" can be whatever data from your sketch you want to log
    URL += "&Key2=";   //"Key2" must match a column name in your spreadsheet
    URL += "value2";     //"value2" can be whatever data from your sketch you want to log
                       //you can add as many key/value pairs as you need to...
    client.get(URL);
    Serial.println(URL);
    Serial.print(F("Returned value: "));
    Serial.println(client.get(URL));


}

vettedude:
Returned value: 18943

when i made the variable global i get 53759

Time to look at the documentation for the HttpClient library to see what those values might mean. Seems strange that the value is different when the variable is global.

If you are using the library from https://github.com/arduino-libraries/ArduinoHttpClient/blob/master/src it looks like the function should be returning 0 for success and a small negative number (-1 through -4) for an error.

    /** Connect to the server and start to send a GET request.
      @param aURLPath     Url to request
      @return 0 if successful, else error
    */
    int get(const char* aURLPath);
    int get(const String& aURLPath);

Something is terribly wrong.