Suzanne
Suzanne

Reputation: 754

Google Sheets API: proper GET construction

I want to get the value of Sheet2's cell A2 in Google Sheet ID "ABC123" using a GET construction.

https://sheets.googleapis.com/v4/spreadsheets/ABC123/values:batchGet?ranges=Sheet2!A2:A2&key=myverysecretkey123

gives me...

{
  "error": {
    "code": 403,
    "message": "The caller does not have permission",
    "status": "PERMISSION_DENIED"
  }
}

I created the API key at https://console.developers.google.com/apis/credentials but how do I connect Google Sheet ID "ABC123" with this API? (or is that even the next step?)

Upvotes: 0

Views: 135

Answers (1)

ReyAnthonyRenacia
ReyAnthonyRenacia

Reputation: 17651

There's such thing as Authorization and Scopes when performing such requests. Try the Javascript Quickstart so you can see the AUTH flow including the use of scopes.

There's a snippet there where GET is used

function listMajors() {

        gapi.client.sheets.spreadsheets.values.get({
          spreadsheetId: '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms',
          range: 'Class Data!A2:E',
   . . . 

Upvotes: 1

Related Questions