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

WordPress: Functions inside while loop with variable in the name
How to access url project in server by public?
XAMPP services cannot be installed or uninstalled while the service is running! Apache
How to parse a string without losing plus sign in PHP?
PHP Laravel Parents inherit dynamic static parameters from children
WordPress: When trying to save a menu item in /wp-admin/nav-menus.php a download appears
Passing the values of my radio buttons into an array
PHP and MySQL how to query decimal column
Function does not give value of variables
Display Woocommerce products in tabs and lightbox on category page
PHP to set Wordpress post featured image as background
getUrlRules - switch to controller
Laravel 5.3 - Database slave failover - get 'host' name used
nearest date in php strtotime
Can't use the get method for PHP script
Inserting an array values depends on data table with condition (nested array)

Categories

HOME
ionic2
android-espresso
facebook-messenger
postgresql-9.4
transactions
loopbackjs
nsview
whmcs
minecraft
roku
msmq
twitter-oauth
fireloop
graphdb
ex
uima
eclipse-emf
msdeploy
tf-idf
guice
monitor
source-insight
instructions
private-key
restful-architecture
forms-authentication
elastica
hidden-markov-models
viewcontroller
git-tfs
type-inference
oracle-bmcs
gcal
beeline
gestures
visual-format-language
android-webservice
line-intersection
ltrace
perl-data-structures
boost-compute
ipywidgets
groovyfx
right-to-left
vaadin4spring
currency-exchange-rates
wikimedia-commons
in-app-billing
jnlp
wlanapi
angular-amd
tree-structure
scala-swing
cakephp-2.2
mobile-country-code
coding-efficiency
screwturn
jomsocial
jmenubar
rautomation
dynamic-rdlc-generation
dibs
aero
spiral
arel
cgrectmake
story
java.lang.class
acpi
yuidoc
boost-foreach
snackjs
nsconnection
libxslt
hungarian-notation
3-tier
icon-language
server-load

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