Using Google Spreadsheet as JSON file using tablet

2019-08-15 08:08发布

问题:

I'm a relative newbie when it comes to coding, especially javascript. I currently am trying to populate a table from a google spreadsheet, which will update when the spreadsheet is.

I followed this tutorial word for word (basically all you need to do is replace the key with your own to specify your spreadsheet, and make sure its both published and public, which I've done)

http://dataforradicals.com/the-absurdly-illustrated-guide-to-sortable-searchable-online-data-tables/

I just get a bad request 400 error referring to my spreadsheet. If I visit the spreadsheet generated directly I just get the words...

"Invalid query parameter value for sq."

https://spreadsheets.google.com/feeds/list/1UcfO9GHePQrcixZB_R9uVXr1vHVqVTDg7DdsOjpm-K0/od6/public/values?alt=json-in-script&sq=&callback=Tabletop.callbacks.tt140241226993949106

I can visit my spreadsheet with the link I was given when I published it here..

[maximum links reached but the structure is different]

As you can see the domain structure is different. I fear that "Tabletop to Datatables" is adding an outdated url to the start of that link but can't find where it actually applies it.

The only reason I would think thats not happening is because the example in the tutorial still works! And the link it refers to is the old style URL too

I'm baffled, please help if you can. All suggestions appreciated

回答1:

The query string includes a parameter without a value, &sq=.

https://spreadsheets.google.com/feeds/list/1UcfO9GHePQrcixZB_R9uVXr1vHVqVTDg7DdsOjpm-K0/od6/public/values?alt=json-in-script&sq=&callback=Tabletop.callbacks.tt140241226993949106
                                                                                                                            ^^^^

Try this, with that parameter completely removed...

https://spreadsheets.google.com/feeds/list/1UcfO9GHePQrcixZB_R9uVXr1vHVqVTDg7DdsOjpm-K0/od6/public/values?alt=json-in-script&callback=Tabletop.callbacks.tt140241226993949106



回答2:

There is an updated version of this project. Any necessary updates are included here: https://github.com/scottpham/tabletop-to-datatables

Try with the updated versions of all js libraries.

Check the link and remove the extra string after pub. That part of link is not necessary and may cause issues.

According to google:

The 400 Bad Request error is an HTTP status code that means that the request you sent to the website server, often something simple like a request to load a web page, was somehow incorrect or corrupted and the server couldn't understand it.

Good luck