2

Am trying to Insert My data's Into google Sheet API . So i followed this Link

After trying that am Getting no Error as PUT 400() in my console, in my Network Header

    Request URL:https://sheets.googleapis.com/v4/spreadsheets/1sd4HEFMsK3WJyHgcs1crX-30LqkBum30kxdH0qCwL5Y/values/Sheet1!A1:B1?valueInputOption==USER_ENTERED
Request Method:PUT
Status Code:400 
Remote Address:74.125.68.95:443

and my Network Response is

   {
  "error": {
    "code": 400,
    "message": "Invalid value at 'value_input_option' (TYPE_ENUM), \"=USER_ENTERED\"",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "value_input_option",
            "description": "Invalid value at 'value_input_option' (TYPE_ENUM), \"=USER_ENTERED\""
          }
        ]
      }
    ]
  }
}

. What i did wrong here , Or still i have to add stuffs into my code ? . Can someone Help/Clarify me . Here is my HTML ,

<div ng-controller="BasicExampleCtrl">

<header data-ng-include="'app/views/header.html'"></header>
<div class="header" data-ng-include="'app/views/menu.html'"></div>
<h2>Welcome Google SpreadSheet Page</h2>

   <button class="btn btn-primary"
   data-ng-click="read()" style="position: absolute;width: 199px;height: 35px;left: 0px;top: 190px;">View In GoogleSheets</button>
</div>

<iframe id='ifr' src='https://docs.google.com/spreadsheets/d/1sd4HEFMsK3WJyHgcs1crX-30LqkBum30kxdH0qCwL5Y/edit#gid=0'
style="position: absolute;width: 100%;height: 100%;left: 0px;top: 250px;" >
 </iframe>

 <iframe id='ifr' src='https://docs.google.com/spreadsheets/d/1sd4HEFMsK3WJyHgcs1crX-30LqkBum30kxdH0qCwL5Y/edit#gid=0'style="position: absolute;width: 100%;height: 100%;left: 0px;top: 250px;" >
 </iframe>

Here is My Js Code ,

$scope.read = function () {

    var params = {
               "range":"Sheet1!A1:B1",
               "majorDimension": "ROWS",
               "values": [
               ["Hello","World"]
              ],
         }  

     var xhr = new XMLHttpRequest();
     xhr.open('PUT', 'https://sheets.googleapis.com/v4/spreadsheets/1sd4HEFMsK3WJyHgcs1crX-30LqkBum30kxdH0qCwL5Y/values/Sheet1!A1:B1?valueInputOption==USER_ENTERED;headers=false');

     xhr.setRequestHeader('Authorization', 'Bearer ' + access_token);
      xhr.send(JSON.stringify(params));


            };

    }]);
0

1 Answer 1

3

You have valueInputOption==USER_ENTERED instead of valueInputOption=USER_ENTERED. Two equal signs instead of one. The error message is telling you the same: "Invalid value at 'value_input_option' (TYPE_ENUM), \"=USER_ENTERED\"" -- =USER_ENTERED isn't a valid value, but USER_ENTERED is.

Sign up to request clarification or add additional context in comments.

3 Comments

I found that on Yesterday , It was my Mistake..Anyway thanks @Sam Berlin :)
Am using OAUTH 2.0 playground access_token for Authentication Purpose but it valid's for just 1Hour only. How can i get Permanent Validation ?
Please ask a different SO question for that, @SaravanaKumar.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.