0
votes

I'm trying to insert and name a new worksheet into an existing Google Sheet using java-script in the browser.

When using the Spreadsheets V3 API in Google's OAuth Playground to try to Insert a Worksheet (VIA the "Insert Worksheets" operation), I get an error 415: "Content-Type application/json is not a valid input type."

I've tried using all the default content-types Google provides in a drop-down, and they all result in the above error. I've been unable to find documentation for the Spreadsheets V3 API aside from what's in the OAuth playground.

Does anyone know the correct content type / how to insert a work sheet into a Google Sheet using java-script browser code?

Thanks!

Summary/Solution:

1

1 Answers

1
votes

Spreadsheets v3 is now a Legacy Version: enter image description here

You can use v4, and the migration documentation can help convert from v3 to v4. I've tried using the v4 in the OAuth 2.0 :

POST /v4/spreadsheets HTTP/1.1
Host: sheets.googleapis.com
Gdata-version: 3.0
Content-length: 61
Content-type: application/json
Authorization: Bearer ACCESS_TOKEN
{
  "properties": {
    "title": "Test Sheets (local)2"
  }
}

This request successfully create a sheet in my drive: enter image description here

Hope this helps.