I'm using Google SpreadSheet and IFTTT to do a DB Call Log of my phone, this is working perfect. Now I'm trying to populate a form in a web page by API from this DB Call Log. I would like to send lastRow to my API every time IFTTT populate the Sheet. The first Row in the Sheet is populated with headers name: departament, first_name, last_name, email, phone, deadline.
So i manage to send data to API like this:
function myFunction() {
var data = {
'department': 1,
'first_name' : 'Test',
'last_name' : 'test',
'email' : '[email protected]',
'phone' : ["0700000000"],
'deadline' : '2017-04-10T00:00'
}
var payload = JSON.stringify(data)
var headers = {
'AUTHORIZATION': 'Token b8473654v6345teryrby456yrtyrtyertytdvfh87afc',
// Add any other required parameters for XXX API.
};
var url = 'http://api.XXX.com/api/1.0/clients/';
var options = {
'method': 'post',
'contentType': 'application/json',
'headers': headers,
'payload' : payload,
};
var response = UrlFetchApp.fetch(url, options);
}
Now i need to automate it but i don't know how:
(this is a SpreadSheet question) IFTTT populate the "deadline" column in this format "April 10, 2017 at 01:54PM" however the needed format for API is "2017-04-10T13:54", how to auto modify it?
to get the values from Sheet cells (from lastRow) and send them throw json payload
to set a trigger event so the script trigger's every time IFTTT populates a new Row in the Sheet.
Thank you!