{"action":"created","issue":{"url":"https://api.github.com/repos/sendgrid/sendgrid-php/issues/148","labels_url":"https://api.github.com/repos/sendgrid/sendgrid-php/issues/148/labels{/name}","comments_url":"https://api.github.com/repos/sendgrid/sendgrid-php/issues/148/comments","events_url":"https://api.github.com/repos/sendgrid/sendgrid-php/issues/148/events","html_url":"https://github.com/sendgrid/sendgrid-php/issues/148","id":74400158,"number":148,"title":"Guzzle Causing Json Encoding Error When Message Body is too large","user":{"login":"sokser","id":5604335,"avatar_url":"https://avatars.githubusercontent.com/u/5604335?v=3","gravatar_id":"","url":"https://api.github.com/users/sokser","html_url":"https://github.com/sokser","followers_url":"https://api.github.com/users/sokser/followers","following_url":"https://api.github.com/users/sokser/following{/other_user}","gists_url":"https://api.github.com/users/sokser/gists{/gist_id}","starred_url":"https://api.github.com/users/sokser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sokser/subscriptions","organizations_url":"https://api.github.com/users/sokser/orgs","repos_url":"https://api.github.com/users/sokser/repos","events_url":"https://api.github.com/users/sokser/events{/privacy}","received_events_url":"https://api.github.com/users/sokser/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-08T15:24:45Z","updated_at":"2015-06-16T13:55:08Z","closed_at":null,"body":"After hours of searching I found that the new version of sendgrid-php is returning a json error if the message body is too large. I kept getting the following error:\r\n````\r\nPHP Fatal error:  Uncaught exception 'Guzzle\\Common\\Exception\\RuntimeException' with message 'Unable to parse response body into JSON: 4' in /home/Email/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Response.php:861\r\nStack trace:\r\n#0 /home/Email/vendor/sendgrid/sendgrid/lib/SendGrid.php(122): Guzzle\\Http\\Message\\Response->json()\r\n#1 /home/Email/vendor/sendgrid/sendgrid/lib/SendGrid.php(101): SendGrid->postRequest('/api/mail.send....', Array)\r\n#2 /home/Email/email.php(712): SendGrid->send(Object(SendGrid\\Email))\r\n#3 /home/Email/main.php(103): Email->generateEmail(Array, NULL)\r\n#4 /home/Email/main.php(154): Main->run()\r\n#5 {main}\r\n  thrown in /home/Email/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Response.php on line 861\r\n\r\nFatal error: Uncaught exception 'Guzzle\\Common\\Exception\\RuntimeException' with message 'Unable to parse response body into JSON: 4' in /home/Email/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Response.php:861\r\nStack trace:\r\n#0 /home/Email/vendor/sendgrid/sendgrid/lib/SendGrid.php(122): Guzzle\\Http\\Message\\Response->json()\r\n#1 /home/Email/vendor/sendgrid/sendgrid/lib/SendGrid.php(101): SendGrid->postRequest('/api/mail.send....', Array)\r\n#2 /home/Email/email.php(712): SendGrid->send(Object(SendGrid\\Email))\r\n#3 /home/Email/main.php(103): Email->generateEmail(Array, NULL)\r\n#4 /home/Email/main.php(154): Main->run()\r\n#5 {main}\r\n  thrown in /home/Email/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Response.php on line 861\r\n````\r\nWhen editing /home/Email/vendor/sendgrid/sendgrid/lib/SendGrid.php to print out the response, the message actually was:\r\n```\r\nGuzzle\\Http\\Message\\Response Object\r\n(\r\n    [body:protected] => Guzzle\\Http\\EntityBody Object\r\n        (\r\n            [contentEncoding:protected] => \r\n            [rewindFunction:protected] => \r\n            [stream:protected] => Resource id #190\r\n            [size:protected] => \r\n            [cache:protected] => Array\r\n                (\r\n                    [wrapper_type] => PHP\r\n                    [stream_type] => TEMP\r\n                    [mode] => w+b\r\n                    [unread_bytes] => 0\r\n                    [seekable] => 1\r\n                    [uri] => php://temp\r\n                    [is_local] => 1\r\n                    [is_readable] => 1\r\n                    [is_writable] => 1\r\n                )\r\n\r\n            [customData:protected] => Array\r\n                (\r\n                )\r\n\r\n        )\r\n\r\n    [reasonPhrase:protected] => Request Entity Too Large\r\n    [statusCode:protected] => 413\r\n    [info:protected] => Array\r\n        (\r\n            [url] => https://api.sendgrid.com/api/mail.send.json\r\n            [content_type] => text/html\r\n            [http_code] => 413\r\n            [header_size] => 158\r\n            [request_size] => 183\r\n            [filetime] => -1\r\n            [ssl_verify_result] => 0\r\n            [redirect_count] => 0\r\n            [total_time] => 0.116375\r\n            [namelookup_time] => 0.001744\r\n            [connect_time] => 0.022283\r\n            [pretransfer_time] => 0.093488\r\n            [size_upload] => 98304\r\n            [size_download] => 192\r\n            [speed_download] => 1649\r\n            [speed_upload] => 844717\r\n            [download_content_length] => 192\r\n            [upload_content_length] => 32503066\r\n            [starttransfer_time] => 0.093494\r\n            [redirect_time] => 0\r\n            [redirect_url] => \r\n            [primary_ip] => 184.173.190.227\r\n            [certinfo] => Array\r\n                (\r\n                )\r\n\r\n            [primary_port] => 443\r\n            [local_ip] => 104.130.119.20\r\n            [local_port] => 41533\r\n        )\r\n\r\n    [effectiveUrl:protected] => https://api.sendgrid.com/api/mail.send.json\r\n    [headers:protected] => Guzzle\\Http\\Message\\Header\\HeaderCollection Object\r\n        (\r\n            [headers:protected] => Array\r\n                (\r\n                    [server] => Guzzle\\Http\\Message\\Header Object\r\n                        (\r\n                            [values:protected] => Array\r\n                                (\r\n                                    [0] => nginx\r\n                                )\r\n\r\n                            [header:protected] => Server\r\n                            [glue:protected] => ,\r\n                        )\r\n\r\n                    [date] => Guzzle\\Http\\Message\\Header Object\r\n                        (\r\n                            [values:protected] => Array\r\n                                (\r\n                                    [0] => Fri, 08 May 2015 15:18:36 GMT\r\n                                )\r\n\r\n                            [header:protected] => Date\r\n                            [glue:protected] => ,\r\n                        )\r\n\r\n                    [content-type] => Guzzle\\Http\\Message\\Header Object\r\n                        (\r\n                            [values:protected] => Array\r\n                                (\r\n                                    [0] => text/html\r\n                                )\r\n\r\n                            [header:protected] => Content-Type\r\n                            [glue:protected] => ,\r\n                        )\r\n\r\n                    [content-length] => Guzzle\\Http\\Message\\Header Object\r\n                        (\r\n                            [values:protected] => Array\r\n                                (\r\n                                    [0] => 192\r\n                                )\r\n\r\n                            [header:protected] => Content-Length\r\n                            [glue:protected] => ,\r\n                        )\r\n\r\n                    [connection] => Guzzle\\Http\\Message\\Header Object\r\n                        (\r\n                            [values:protected] => Array\r\n                                (\r\n                                    [0] => close\r\n                                )\r\n\r\n                            [header:protected] => Connection\r\n                            [glue:protected] => ,\r\n                        )\r\n\r\n                )\r\n\r\n        )\r\n\r\n    [headerFactory:protected] => Guzzle\\Http\\Message\\Header\\HeaderFactory Object\r\n        (\r\n            [mapping:protected] => Array\r\n                (\r\n                    [cache-control] => Guzzle\\Http\\Message\\Header\\CacheControl\r\n                    [link] => Guzzle\\Http\\Message\\Header\\Link\r\n                )\r\n\r\n        )\r\n\r\n    [params:protected] => Guzzle\\Common\\Collection Object\r\n        (\r\n            [data:protected] => Array\r\n                (\r\n                )\r\n\r\n        )\r\n\r\n    [protocol:protected] => HTTP\r\n    [protocolVersion:protected] => 1.1\r\n)\r\n````\r\nDecreasing the number of users in each email seemed to solve the problem. But sendgrid-php should properly encode this as json rather than killing the program."},"comment":{"url":"https://api.github.com/repos/sendgrid/sendgrid-php/issues/comments/112440603","html_url":"https://github.com/sendgrid/sendgrid-php/issues/148#issuecomment-112440603","issue_url":"https://api.github.com/repos/sendgrid/sendgrid-php/issues/148","id":112440603,"user":{"login":"smith2martin","id":5056557,"avatar_url":"https://avatars.githubusercontent.com/u/5056557?v=3","gravatar_id":"","url":"https://api.github.com/users/smith2martin","html_url":"https://github.com/smith2martin","followers_url":"https://api.github.com/users/smith2martin/followers","following_url":"https://api.github.com/users/smith2martin/following{/other_user}","gists_url":"https://api.github.com/users/smith2martin/gists{/gist_id}","starred_url":"https://api.github.com/users/smith2martin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smith2martin/subscriptions","organizations_url":"https://api.github.com/users/smith2martin/orgs","repos_url":"https://api.github.com/users/smith2martin/repos","events_url":"https://api.github.com/users/smith2martin/events{/privacy}","received_events_url":"https://api.github.com/users/smith2martin/received_events","type":"User","site_admin":false},"created_at":"2015-06-16T13:55:08Z","updated_at":"2015-06-16T13:55:08Z","body":"In my case this ended up truly being a size issue. There were indeed attachments, and they were indeed sufficiently large to put the total message size above the 19.5 meg threshold. Sorry bout that."}}