Category : urlfetch

I have a request that returns a large JSON: function fetchDataFromApi(request, params) { var url = ‘https://someurl/get-records?’ + ‘school=someSchool&’ + ‘year=’; var yearToday = parseInt(new Date().getFullYear()); var requests = []; for (var i = 2011; i < yearToday; i++) { requests.push(url + i); } return JSON.parse(UrlFetchApp.fetchAll(requests).map(function(e) { return e.getContentText()})); } I have sliced it by ..

Read more

I want to get data from Google Sheet, and then display it as a dropdown selections The code below is working well. A working example can be found here https://codepen.io/imccw/pen/NWpEVwj <html> <body onload="loadDate()"> <select id="newDate"> <option value="Choose-a-date">Choose a date</option> <span id="selections"></span></select> <div id="display"></div> </body> </html> function loadDate(){ const url = "https://docs.google.com/spreadsheets/d/e/2PACX-1vS5xmOpa8T6-dHJK8THOnp-25xWWHWUy9g__5tnTpyVyYYiTiY7mtPD0RDB3qVHDKucsjvPSd-C9-Le/pub?output=csv"; fetch(url).then(response => response.text()).then(text => ..

Read more

I’m looping through a list of Amazon Products to get the negative reviews from each product in the list. However, about 90% of the time, UrlFetchApp.fetch("url").getContentText(); will return a short version of the HTML that doesn’t contain any of the actual content on the page. Right now I’m forcing the loop to try again and ..

Read more

I want to retrieve the current prices of specific crypto currencies and update some fields in my google sheet. Here a short codesnippet: var api_url = "API-URL"; var response = UrlFetchApp.fetch(api_url); var dataAll = JSON.parse(response.getContentText()); @When executing the URL in a Browser, I get this for dataAll: dataAll content on Browser @When executing it in ..

Read more

Using https://developer.safetyculture.io/?shell#add-a-response I have the following: function addResponse(){ var url = ‘https://api.safetyculture.io/response_sets/responseset_id/responses’; var myBody = {"label": "String To Add"}; var headers = {"Authorization" : ‘Bearer ‘ + ‘api_key’}; var params = { ‘method’: ‘POST’, //’muteHttpExceptions’: true, ‘headers’: headers, ‘contentType’: ‘application/json’, ‘payload’: myBody }; UrlFetchApp.fetch(url, params); } I am able to get the responseset (https://developer.safetyculture.io/?shell#get-a-global-response-set) so ..

Read more