googleworkspace / php-samples

PHP samples for Google Workspace APIs
Apache License 2.0
288 stars 348 forks source link

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

Closed sushantwebmingo closed 5 years ago

sushantwebmingo commented 6 years ago

(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
    1. above error is showing

Specifications

Fatimamohammad08 commented 6 years ago

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 commented 6 years ago

Did you manage to display data from your own spreadsheet?

grant commented 6 years ago

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 commented 6 years ago

@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 commented 6 years ago

@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 commented 6 years ago

@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 commented 5 years ago

@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 commented 5 years ago

I can get particular data of given name by spreadsheet api but not by ther query. We can not apply query here.

From: Fatimamohammad08 [mailto:notifications@github.com] Sent: Sunday, September 23, 2018 6:34 PM To: gsuitedevs/php-samples Cc: sushantwebmingo; Mention Subject: Re: [gsuitedevs/php-samples] quickstart.php for accessing data from spreadsheet of google (#15)

@grant https://github.com/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 Alexander?

— You are receiving this because you were mentioned. Reply to this email directly, view https://github.com/gsuitedevs/php-samples/issues/15#issuecomment-423815107 it on GitHub, or mute https://github.com/notifications/unsubscribe-auth/AoAAPdP0GqDEZCkpa8-1M0dHafYXnscHks5ud4bDgaJpZM4VnuuJ the thread.Image removed by sender.

Fatimamohammad08 commented 5 years ago

@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 commented 5 years ago

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.