Reputation: 407
I'm trying to retrieve the JSON output from one of my spreadsheets. I'm looking for the second tab/page in my sheet.
var url2 = "https://spreadsheets.google.com/feeds/list/" + spreadsheetID2 + "/od6/public/values?alt=json";
$.getJSON(url2, function(data) {
//some code here
});
When I publish my spreadsheet to the web this piece is added to my link
?gid=72574160&single=true
I tried to put it on different places in my link but every time I get an error like this:
XMLHttpRequest cannot load [url] No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
My question is: how can I get the JSON from one specific tab?
Thanks!
Upvotes: 0
Views: 792
Reputation: 192
Found the solution to this: https://spreadsheets.google.com/feeds/cells/SPREADSHEETID/NUMBEROFTAB/public/values?alt=json-in-script&callback=doData
Spreadsheet: https://docs.google.com/spreadsheets/d/1CeXMU7IRDWtj57l2nM2rQHkHpkNH3jhsG_pGZ8S4CzY/edit?usp=sharing
json tab 1: https://spreadsheets.google.com/feeds/cells/1CeXMU7IRDWtj57l2nM2rQHkHpkNH3jhsG_pGZ8S4CzY/1/public/values?alt=json-in-script&callback=doData
json tab 2: https://spreadsheets.google.com/feeds/cells/1CeXMU7IRDWtj57l2nM2rQHkHpkNH3jhsG_pGZ8S4CzY/2/public/values?alt=json-in-script&callback=doData
Upvotes: 3
Reputation: 407
Apparently there is a nice bypass. You can access your sheet through this link.
https://spreadsheets.google.com/feeds/worksheets/YOUR_SPREADSHEET_ID/private/full
After that you can search for your tab name and spreadsheet URL and take that url to getJSON.
Upvotes: -2