Closed
Description
Hi, I just upgraded from version 4.1.1 to 4.1.2 and noticed that the send function is erroring because of the new type declarations introduced in this version.
Something like this is no longer working.
$sendgrid = new \SendGrid($apiKey);
$email = new Mail(
new From($this->fromMail, $this->fromName),
new To($sendTo),
'Test Email'
);
$email->addContent('text/plain', 'This is the plain text content of the email.');
$response = $sendgrid->send($email);
The error it shows says:
SendGrid\Client::makeRequest): Argument #3 ($body) must be of type ?array, SendGrid\Mail\Mail given, called in /var/www/html/src/vendor/sendgrid/php-http-client/lib/Client.php on line 662
Metadata
Metadata
Assignees
Labels
No labels
Activity
ozanuzer commentedon Apr 8, 2025
I also get the same error. I fixed version to 4.1.1. I will revert back when bug will fixes
p.s "$email->jsonSerialize()" did not fix the error.
mayocca commentedon Apr 8, 2025
Fwiw sendgrid/sendgrid-php#1123 would fix this error but there are a few ones that also surfaced with the new types for
Client::makeRequest
which are mentioend in sendgrid/sendgrid-php#1124.Something like this patch should fix the issue from this side until there's a better solution:
I didn't have a chance to test this yet since it would need to be tested e2e with both packages and the applied patch.
Tagging @twilio-dx since this is currently breaking all new sdk installs.
tiwarishubham635 commentedon Apr 9, 2025
Hi! We are working on this. Will be releasing the fixed version at the earliest