php


Google Sheets API V4 PHP - inserting data 400 error


First time using Google API, bit confused at the documentation, wonder if someone could help me.
I am getting this error:
Fatal error: Uncaught exception 'Google_Service_Exception' with message '{
"error": {
"code": 400,
"message": "Invalid value at 'data.values' (type.googleapis.com/google.protobuf.ListValue), \"[{\"Name\":\"a\"}]\"",
"errors": [
{
"message": "Invalid value at 'data.values' (type.googleapis.com/google.protobuf.ListValue), \"[{\"Name\":\"a\"}]\"",
"domain": "global",
"reason": "badRequest"
}
],
"status": "INVALID_ARGUMENT"
}
}
Checked with the Google API Docs, which says, do this:
$values = array(
array(
// Cell values ...
),
// Additional rows ...
);
$body = new Google_Service_Sheets_ValueRange(array(
'values' => $values
));
$params = array(
'valueInputOption' => $valueInputOption
);
$result = $service->spreadsheets_values->update($spreadsheetId, $range, $body, $params);
I've tried to enter different values in that $value array, but no matter what I try I just get Invalid Value at data.values.
Ok, bit of an update, I think I might have been sending to many requests, when I got home I didn't get that error, not sure if anyone can confirm if thats an issue?
However, I found a bit of a solution that helped me sort it out from here: Store data in Google Sheets
So, instead of using my:
$values = array(
array(
// Cell values ...
),
// Additional rows ...
);
I used:
$values = [
["Name", "Roll No.", "Contact"],
["Anis", "001", "+88017300112233"],
["Ashik", "002", "+88017300445566"]
];

Related Links

php script works in browser but trows fatal error at command line
In Magento what is the correct data flow from POST to controller to model to block to template?
Login in Android to an Api System
echo correct message without slash
only want to show some of the text
PHP View Counter
Getting the pdf invoice from WHMCS?
uploading videos into a folder and its link to database using php
Choosing random data from an array (PHP)?
PHPExcel date getting substracted on some rows
Facebook fql query by php
Foreach loop only runs once
rewrite rule not working on fast cgi server, PHP
Socket error “unable to connect to”
htaccess environmental variables merits and demerits
Sorting array - child after its parent, but keep parents positions to each other

Categories

HOME
office365
visual-studio
ionic2
firebase
mc
xcode
yaml
clearcase
bots
concurrency
transactions
docker-cloud
elisp
tibco
jpa-criteria
bellman-ford
fireloop
ex
jodatime
jaspersoft-studio
bluemix-mobile-services
weex
web-analytics
gollum-wiki
fluent-migrator
cell
restier
software-packaging
ratio
raima
router
acrobat
instructions
knights-tour
sql-execution-plan
ms-media-foundation
autoencoder
nppexec
keyboard-layout
strapi
rdp
flowchart
yoast
vungle-ads
elasticsearch-aggregation
virtual-memory
latexml
jshint
spring.net
sesame
oracle-fusion-apps
portal
traversable
piping
odp.net-managed
node-glob
jeasyui
vimperator
okta-api
psd
myfaces
linuxbrew
ambiguity
jnlp
embeddedwebserver
unidata
kotlin-android-extensions
deque
mathematical-expressions
phonegap-facebook-plugin
password-recovery
berkeley-db-xml
prism.js
commenting
zend-search-lucene
jack
mod-perl
profiles
pbkdf2
visual-c++-2005
notifyjs
libxml-js
aero
significant-digits
xmlwriter
cgrectmake
daap
playorm
chronometer
system-information
struts2-s2hibernate
mvcrecaptcha
drawimage
play2-mini
botnet
turbine
resharper-5.1
aspbutton
projectpier
data-retrieval
inversion
xap
index.dat
datagridcolumn
suggestbox
rootkit

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App