1
votes

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.

1

1 Answers

1
votes

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"]
    ];