-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request to the Resend API failed. Reason: Syntax error #71
Comments
Just spotted this stacktrace in Horizon that I thought might be helpful: |
@flatcapco are you using the batch-mail api by a chance? I had the same issue when I wanted to send batch-mails via resend. example code: $mails = $users->map(function ($user) {
$mail = new MailClass($params); // as an example
return [
'from' => "...",
'to' => [ "..."],
'subject' => "...",
'html' => "...",
];
});
// the batch API endpoint allows 100 mails at once at most
$mails->chunk(100)->each(function($chunk){
$resend->batch->send($chunk->toArray());
}); with the snippet above the first call was always successful but all the following requests got an error: {
"name": "validation_error",
"message": "The `request.body` field must be an `array`.",
"statusCode": 422
} I then noticed that the index of the array chunks caused the issue. If the array doesn't start at 0, the request body is handled as an object instead of an array. By changing $mails->chunk(100)->each(function ($chunk) use ($resend) {
$batch = $chunk->values()->toArray(); // resetting the array-index
$resend->batch->send($batch);
}); the batch-mails worked as expected. PS: |
Hey @SahinU88 I'm not using batch mail sadly so that doesn't fix it they are all queued up a separate mails |
Not sure if I can help but could you provide a code snippet showing how you use the mail service? |
Hi, We are also facing the same issue. We have had these errors over 143 times now.
Just like @flatcapco mentioned, it happens randomly and it doesn't add up because all other emails should fail ideally. |
This exception has been bugging me for so long as well, that I have decided to mute it for now in my exception handler 🤷♂️ |
I've reported this to resend via the message box but also reporting here.
I've got fairly standard mailables in my laravel 11 project. Every 100 emails or so I get this random error. Its happened 3x now and on different mailables. Because my jobs are set to retry a few times, this always goes out successfully on the 2nd try.
Which is even more confusing because if there was truly a syntax error we'd have another fail?
There is nothing for the fail in the resend log gui.
And I'm having a hard time where I can take it from here.
Using these versions:
"resend/resend-laravel": "^0.14.0",
"laravel/framework": "^11.33",
The text was updated successfully, but these errors were encountered: