Reputation: 11
I'm new to google drive api.
When I run the following piece of code (I got it from here) I get the following error:
Fatal error: Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error:
POST https://spreadsheets.google.com/feeds/list/1AnZ9_h3jnKogvx5AIftxypGnGM0f2P4r_ut4RGFC7AQ/od6/private/full
resulted in a400 Bad Request
response'
The code:
$postBody = '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gsx="http://schemas.google.com/spreadsheets/2006/extended"><gsx:gear>more gear</gsx:gear><gsx:quantity>44</gsx:quantity></entry>';
echo "BBBB<br>";
$httpClient = new GuzzleHttp\Client(['headers' => $headers]);
echo "CCCC<br>";
$resp = $httpClient->request($method, $url, ['body' => $postBody]);
echo "DDDD<br>";
$body = $resp->getBody()->getContents();
$code = $resp->getStatusCode();
$reason = $resp->getReasonPhrase();
echo "$code : $reason\n\n";
echo "$body\n";
Can some one help me find the error?
Upvotes: 0
Views: 2272
Reputation: 11
Although this is not related to Guzzle at all, I found another method to do my task. After creating the form go to Responses menu and select 'Get pre-filled URL'
Fill the dummy form you get and submit. Then you will be given a URL. Here change 'viewResponse' to 'formResponse'
Append the data to necessary parts of the URL. Send request to this URL to fill the google form automatically and submit
Upvotes: 1