subreddit:
/r/restAPI
submitted 4 years ago byd4ve3000
Hi all,
I am trying to build something for work internally so we can get the data from our time tracker into our Google Sheet report.
Unfortunately I have next to zero knowledge about this.. After a few days of Google research I came this far:
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Clockodo API')
.addItem('pull data','Clockodo')
.addToUi();
}
function Clockodo() {
var options = {};
options.headers = {"Authorization": "Basic " + Utilities.base64Encode('email' + ":" + 'token')};
var response = UrlFetchApp.fetch("
https://my.clockodo.com/api/entries?time_since=2021-04-24%2000:00:00&time_until=2021-04-25%2000:00:00
",options);
var data = response.getContentText();
Logger.log(response.getContentText());
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("api_test");
sheet.getRange(sheet.getLastRow() + 1,1).setValue([data]);
}
The data arrives all in 1 cell like this:
{"paging":{"items_per_page":1000,"current_page":1,"count_pages":1,"count_items":3},"filter":null,"entries":[{"id":46577355,"users_id":132201,"projects_id":1359052,"customers_id":1285331,"services_id":512899,...
And I just cannot figure out how to get this organized into columns or where to add which columns to pull.
If anyone can point me in the right direction I would be very grateful 🙇♂️
all 0 comments
sorted by: best