0

The google sheets API documentation states I need to have a sheetID that would show up in the url here (denoted {SHEETID}): https://docs.google.com/spreadsheets/d/{SHEETID}/edit#gid=0

However, when I publish to the web, the URL returned is something along the lines of: https://docs.google.com/spreadsheets/u/1/d/e/2PACX-1vcasfsaf2123Mt_basdf34grGd_1231sfak_D32141sfasfqwer_phealsjsmfdafcmr2S_-n-wzUp/pubhtml

I have also already tried just using the sheetID from the unpublished url and that does not work either.

I'm trying to pull data with react from this sheet but am unable to do so. Does anyone know how else I can get the sheetID?

  • Is this information useful for your situation? https://stackoverflow.com/questions/50997579/how-to-get-the-id-for-a-published-to-the-web-spreadsheet-in-google-apps-scripts/50998812#50998812 – Tanaike Aug 03 '18 at 00:36
  • It seemed to be the same question however it does not help me resolve my issue. When I publish my spreadsheet to the web, the url is as defined above with 2PACX-"" and a bunch of characters.. however I need a spreadsheet ID similar to the following format "1dsdqf0vmAv_389X9anXP7_XN78Xv9EbN3p9yNxU-1kw" – Harman Thind Aug 03 '18 at 01:01
  • I'm really sorry I couldn't help. – Tanaike Aug 03 '18 at 01:01
  • no worries.. i really dont understand why this is the case. Googles API says the spreadsheetID will be in the URL between spreadsheets/d/{SPREADSHEETID}/edit however that is not the case when I publish it to the web – Harman Thind Aug 03 '18 at 01:04
  • Because that's not the document link, that's the published html link – tehhowch Aug 03 '18 at 01:10
  • For example, when the spreadsheet is shared, the URL is ``https://docs.google.com/spreadsheets/d/### fileId ###/edit?usp=sharing``, and you can retrieve the values using ``https://docs.google.com/spreadsheets/d/### fileId ###/export?format=csv`` as CSV. – Tanaike Aug 03 '18 at 01:11
  • so when I use a random spreadsheetID from a spreadsheet I found online, my react app is able to pull info from it correctly, however as soon as i replace that ID with my own, I am getting the following error: "Objects are not valid as a React child (found: object with keys {code, message, status}). If you meant to render a collection of children, use an array instead." Are you familiar with this at all? Does this have to do with my spreadsheet not actually being published to the web – Harman Thind Aug 03 '18 at 01:22
  • If it isn't available in view-as-spreadsheet (not pubhtml), then you'll get an http error – tehhowch Aug 03 '18 at 01:27
  • So what is your recommendation for me to be able to pull data from my spreadsheet into my reactApp? I'm sorry if im not following but have no idea why this is an issue. Like i Said my app pulls data completely fine from a different spreadsheet just not mine @tehhowch – Harman Thind Aug 03 '18 at 01:50
  • Update: For reference, this is the spreadsheet that I am using and my react app is able to pull data from https://docs.google.com/spreadsheets/d/1KTArYwDWrn52fnc7B12KvjRb6nmcEaU6gXYehWfsZSo/edit#gid=0 I followed the tutorial from this website: https://blog.416serg.me/building-an-app-using-google-sheets-api-react-d69681d22ce1 – Harman Thind Aug 03 '18 at 02:04
  • I'm not sure what the question here is... that link has your file ID in it. If you have a different question, related to the access of your given sheet by your react app, you're going to need to ask a question related to that, with the relevant code and complete error message (and the research you've done attempting to resolve that error message). – tehhowch Aug 03 '18 at 02:23
  • apologies let me reiterate, I am able to pull data from a random google sheet i found online by inserting its fileId into my code. However, when I use MY OWN fileId from a sheet I would like to use, I get the following error message "Objects are not valid as a React child (found: object with keys {code, message, status}). If you meant to render a collection of children, use an array instead." So i just don't understand why my app works with any random google sheet but not my own. Do i have to publish it or do something specific with it before I reference its sheet ID? – Harman Thind Aug 03 '18 at 10:49

0 Answers0