Comments (1)
In theory you should just be able to call IMPORTJSONAPI from the onOpen trigger so that the import is run everytime you open the sheet:
function onOpen(e) {
// Code to import data and update spreadsheet
...
}
However there is a problem with this in that the IMPORTJSONAPI makes an external network request which is not allowed from a script called by the onOpen trigger. A better explanation is provided here:
https://stackoverflow.com/questions/55996556/google-apps-script-urlfetchapp-permission
The second option is to add a button to your spreadsheet which does the import when you manually click the button. To do this add the following function to your script:
function UPDATE_DATA() {
var ROW = 1
var COL = 1
var values = IMPORTJSONAPI("http://data.nba.net/10s/prod/v1/2018/teams.json", "$.league.*[*]", "^.~, city, isNBAFranchise")
var numrows = values.length
var numcols = values[0].length
SpreadsheetApp.getActiveSheet().getRange(ROW, COL, numrows, numcols).setValues(values)
}
You will need to change the ROW and COL to where you want to insert the data and also update the IMPORTJSONAPI arguments to your own. Now read the following tuturial which describes how you add a button to your spreadsheet and hook it up to the above function:
https://www.benlcollins.com/apps-script/google-sheets-button/
Hope this helps.
from importjsonapi.
Related Issues (20)
- Using match for results with | or + characters? HOT 1
- Sometimes response output in the cell below formula HOT 9
- Import JSON from sheet HOT 6
- not an issue, just asking for help ! HOT 2
- Do wildcards (*) not work in Column paths? Or am I being stupid... HOT 1
- Working with multiple function calls in sheets HOT 2
- Concatenate strings and parsed data
- not an issue, just asking for help.
- Retrieve JSON with HMAC/SHA256 Auth and custom fields
- Stagger Requests HOT 1
- Support ArrayFormula
- Need some help
- The script somehow blocks the debugger from Google Action Script
- possible to use the script in Excel?
- Split no header data into multiple rows
- Unexpected end of JSON input
- Not an issue
- Importing Multiple URLs HOT 1
- request with api key element HOT 1
- No issue, just requesting assistance HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from importjsonapi.