Hope you're doing well. Im developing a proyect where I need to upload many variables to Google Spreadsheets, for what I'm using IFTTT, which only let me upload 3 values apart from the event name and the upload date.
So, I figured out that to upload more values to my Google Sheet, I'd only need two out of the three values, because I will upload all the variables separated by commas in the slot reserved for "value 1", and a Google Sheet/Excel command to separate it in many cells after uploading them in "value 2".
I tried an example of this in the WebHooks documentation page in IFTTT, and it worked, the problem comes when I create the jsonObject in Arduino IDE, since the code complies and get uploaded to my ESP8266, but in the serial monitor, show me the following error.
14:19:37.419 -> Connecting to maker.ifttt.com 14:19:37.606 -> Request resource: /trigger/my_file_name/with/key/my_key 14:19:37.606 -> {"value1":"0,0,0,0,0,0","value2":"=SPLIT(INDICE(1:2000; FILA();(COLUMNA()-1));",")"} 14:19:38.290 -> HTTP/1.1 400 Bad Request 14:19:38.290 -> Date: Sun, 26 Sep 2021 18:19:36 GMT 14:19:38.290 -> Content-Type: application/json; charset=utf-8 14:19:38.290 -> Content-Length: 68 14:19:38.290 -> Connection: close 14:19:38.290 -> X-Powered-By: Express 14:19:38.290 -> ETag: W/"44-aUxYR3gnF4RvNYXG8uY3kJzvmM0" 14:19:38.290 -> 14:19:38.290 -> {"errors":[{"message":"Unexpected token } in JSON at position 83"}]}Reboot: 14:19:47.425 ->
Seems line a syntax issue, I tried changing (and deleting) characters like "{", "}", but the issues continue, what could be causing this?
The code to create the jsonOject is this:
int test_value = 1;
int t1 = test_value*1;
int t2 = test_value*2;
int t3 = test_value*3;
int t4 = test_value*4;
int t5 = test_value*5;
int t6 = test_value*6;
String sgs = "=SPLIT(INDICE(1:2000; FILA();(COLUMNA()-1));\",\")";
String jsonObject = String("{\"value1\":\"") + t1 + "," + t2 + "," + t3 + "," + t4 + "," + t5 + "," + t6 + "\",\"value2\":\"" + sgs + "\"}";
Serial.println(jsonObject);
I'll thank any advice or recommendation you could grant me!
Your json should be written as
{"value1":"0,0,0,0,0,0","value2":"=SPLIT(INDICE(1:2000; FILA();(COLUMNA()-1));\",\")"}
with additional backslashes. But be careful, sometimes the backslashes disappear by intermediate transformation and must be doubled to avoid this.
So, replace by
String sgs = "=SPLIT(INDICE(1:2000; FILA();(COLUMNA()-1));\\\",\\\")";