Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quickstart.php for accessing data from spreadsheet of google #15

Closed
sushantwebmingo opened this issue Jul 31, 2018 · 10 comments
Closed
Assignees

Comments

@sushantwebmingo
Copy link

sushantwebmingo commented Jul 31, 2018

(Please search existing issues before creating a new one.)

Fatal error: Uncaught exception 'Google_Service_Exception' with message
'{
   "error":{
      "code":400,
      "message":"Unable to parse range: Class Data!A1:B",
      "errors":[
         {
            "message":"Unable to parse range: Class Data!A1:B",
            "domain":"global",
            "reason":"badRequest"
         }
      ],
      "status":"INVALID_ARGUMENT"
   }
}'
in
C:\xampp\htdocs\google_php_api\vendor\google\apiclient\src\Google\Http\REST.php:118 Stack trace: #0
C:\xampp\htdocs\google_php_api\vendor\google\apiclient\src\Google\Http\REST.php(94): Google_Http_REST::decodeHttpResponse(Object(GuzzleHttp\Psr7\Response), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #1 [internal function]: Google_Http_REST::doExecute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #2
C:\xampp\htdocs\google_php_api\vendor\google\apiclient\src\Google\Task\Runner.php(181): call_user_func_array(Array, Array) #3
C:\xampp\htdocs\google_php_api\vendor\google\apiclient\src\Google\Http\REST.php(58): Google_Task_R in
C:\xampp\htdocs\google_php_api\vendor\google\apiclient\src\Google\Http\REST.php on line 118

Expected Behavior

want to show all data of sheet

Actual Behavior

want to show all data of sheet

Steps to Reproduce the Problem

  1. install composer
  2. create credential.json
  3. token.json file created
  4. above error is showing

Specifications

  • PHP version (php -v): 5.4
  • OS (Windows):
@Fatimamohammad08
Copy link

I get the same error whenever I try to change the spreadsheetId in order to view my spreadsheet but not the the one that's already in quickstart.php.

@Fatimamohammad08
Copy link

Did you manage to display data from your own spreadsheet?

@grant
Copy link
Contributor

grant commented Sep 4, 2018

Hi @sushantwebmingo, what sample are you running? Are you sure that the Sheets quickstart was run without modifications?

I've formatted the issue. The error states the problem is with the range: Class Data!A1:B
See https://stackoverflow.com/questions/37893515/google-spreadsheet-api-400-error-bad-request-unable-to-parse-range

@grant
Copy link
Contributor

grant commented Sep 4, 2018

@Fatimamohammad08 It looks like you're using "test!A2:E". The error states it is unable to parse this. Can you try using a range like "A2:E2"?

@Fatimamohammad08
Copy link

@grant hey thanks for the help ! I had a question .
is that possible to pull out only one record from google sheet according to the user ID that's used for authentication?
so that i don't need to pull over the complete spreadsheet and do an if statement?

@grant
Copy link
Contributor

grant commented Sep 5, 2018

@Fatimamohammad08 It is not possible to get just one row or cell. You can sort the sheet and get a range which is the top value, but you can't retrieve a cell by ID.

https://stackoverflow.com/questions/38114591/is-it-possible-to-access-row-id-of-a-google-spreadsheet

That question doesn't relate to this issue though and may be better for StackOverflow.

@Fatimamohammad08
Copy link

Fatimamohammad08 commented Sep 23, 2018

@grant Hello ! I wanted to know how can you fetch the data using a query? for example how would i get a row https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit from this if the student name is Alexandra?

@sushantwebmingo
Copy link
Author

sushantwebmingo commented Sep 24, 2018 via email

@Fatimamohammad08
Copy link

Fatimamohammad08 commented Sep 24, 2018

@grant @sushantwebmingo so if I have a column as ID as my unique Id . Can;t I query like in SQL ?
Because if I use his link below https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/gviz/tq?tqx=out:html&tq=select+A,B,C,D,E+where+A=%27Alexandra%27
it does get the data. but i am unable to understand how to make it work using php.

@grant
Copy link
Contributor

grant commented Oct 18, 2018

You cannot use Sheets like a SQL database or query like a database. Maybe you could try this option:
https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/batchGetByDataFilter

Please use the issue tracker for generic issues as GitHub is used for existing code samples. You can still discuss here if you wish, but I'll close this issue.

@grant grant closed this as completed Oct 18, 2018
sqrrrl pushed a commit that referenced this issue Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants