urlfetch

Invalid Argument with UrlFetch

旧城冷巷雨未停 提交于 2020-08-22 12:03:11
问题 I am trying to run a MongoLab (REST based access to MongoDB) query via Google Apps Script. The URL is generated from the logger is shown below https://api.mongolab.com/api/1/databases/abcd/collections/efgh?apiKey=XXXXXXXXXXXXXXXX&q={"created_on":{"$gte":"Thu Dec 06 00:00:00 PST 2012","$lt":"Thu Dec 06 23:59:59 PST 2012"}} When I type this in the browser, it works and gets me the response I am looking for. But running it via UrlFetchApp gives an "Invalid Argument" error. I see there are

Converting Stripe API syntax to Google Apps Script

醉酒当歌 提交于 2020-07-22 05:50:32
问题 This SO answer correctly explains that since the require Node/JS library is not supported by Google Apps Script, the following code changes must be made to get Stripe to work properly in a GAS project: from const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); (async () => { const product = await stripe.products.create({ name: 'My SaaS Platform', type: 'service', }); })(); to function myFunction() { var url = "https://api.stripe.com/v1/products"; var params = { method: "post",

Rate Limit Error to Nest Thermostat - Response Code 429

a 夏天 提交于 2020-07-19 06:06:06
问题 I use a very cool Google Script I found on Github (source: https://gist.github.com/beezly/9b2de3749d687fdbff3f) to fetch the temperature on my Nest thermostat and log it into a Google Spreadsheet. It is working great when I run the script manually, but not when I use a time trigger to run it automatically. When posting the credential to the API on this line: Line 12: var response = JSON.parse(UrlFetchApp.fetch('https://home.nest.com/user/login', options).getContentText()); The exception

How to login into the Fidelity website and navigate within it?

旧时模样 提交于 2020-06-29 08:31:41
问题 I would love to get some help in logging into the Fidelity website and navigate within it. My attempts so far have not led me to anywhere significant. So here is the code that I have written, after much consultation with answers around the web. The steps are: Login to Fidelity Check if response code not 200, but is 302 or 303 and my code passes this test (with a code of 302). Then I check the number of cookies returned (there were 5) and for each cookie I try to navigate to a different web

GAS: Error 500 while connecting to an API

允我心安 提交于 2020-06-29 04:13:27
问题 I'm trying to connect to Cloud Waitress API, a solution for restaurants, Documentation: https://apidocs.cloudwaitress.com/#orderpromos It's documentation gives an example on how to connect to the API: curl https://api.cloudwaitress.com/v1/orders \ -X POST \ -H "Content-Type: application/json" \ -H "Authorization: YOUR_API_KEY" \ -d ` { "restaurant_id": "xxxxxxx", "limit": 10, "page": 1, "sort": { "created": -1 }, } ` I tried to create a Script in GAS to get the information back to a

jsonp ajax in google script

冷暖自知 提交于 2020-06-23 18:37:05
问题 I'm trying to learn how to query for data from a local government data site (hoping I can teach my math students to do some data analysis). I'm hoping to get the data and insert them into Google Sheets. The following is a sample provided by the official site on how to do a query: var data = { resource_id: '1b702208-44bf-4829-b620-4615ee19b57c', // the resource id limit: 5, // get 5 results q: 'jones' // query for 'jones' }; $.ajax({ url: 'https://data.gov.sg/api/action/datastore_search', data

jsonp ajax in google script

六眼飞鱼酱① 提交于 2020-06-23 18:36:13
问题 I'm trying to learn how to query for data from a local government data site (hoping I can teach my math students to do some data analysis). I'm hoping to get the data and insert them into Google Sheets. The following is a sample provided by the official site on how to do a query: var data = { resource_id: '1b702208-44bf-4829-b620-4615ee19b57c', // the resource id limit: 5, // get 5 results q: 'jones' // query for 'jones' }; $.ajax({ url: 'https://data.gov.sg/api/action/datastore_search', data

How to insert file to a shared drive using REST on Apps Script?

与世无争的帅哥 提交于 2020-06-01 07:37:04
问题 Is there a way that we can upload files to shared drive using POST Method? I don't know how to call the Drive ID of the shared drive and target it to the URL fetch function, is this possible? This is my code: var DriveScope = 'https://www.googleapis.com/auth/drive'; var ServiceAccountPrivateKey ="-----BEGIN PRIVATE KEY----" var ServiceAccountEmail = "drive-uploads@xxxxxxx.com"; function testinRest(){ var service = getDriveService(); var driveID = "XXXXXXXX"; var APIKey = "XXXXXXXXXXXXX"; var