Skip to content
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

Bad request because of schedule date #22

Open
nam-truong-le opened this issue Aug 9, 2024 · 7 comments
Open

Bad request because of schedule date #22

nam-truong-le opened this issue Aug 9, 2024 · 7 comments

Comments

@nam-truong-le
Copy link

Hi team, I'm receiving this error after an upgrade from 1.0.3 to 1.1.2

{"code":"invalid_parameter","message":"Scheduled date should not be less than current date"}

My code is unchanged and this scheduled date is a beta feature. I don't set ScheduledAt in my code. Can you have a look? Thank you!

@nam-truong-le
Copy link
Author

If I add this ScheduledAt: time.Now().Add(5 * time.Second), to my code, it works again but I believe it should work also without setting value for ScheduledAt.

@DimoskiBojan
Copy link

I made a PR that solves this issue: #23

@llstarscreamll
Copy link

I get this error too today, but I was not able to get the response body due to error http2: response body closed. @nam-truong-le you work around worked for me, thanks!!

@gwd
Copy link

gwd commented Sep 20, 2024

@llstarscreamll BTW by digging into the code I discovered that it actually returns an error of type brevo.GenericSwaggerError; you can get the body of the response from the Body() method of that, but has already tried to parse the response as type brevo.ErrorModel. You can fish the error response out by attempting some casting:

	obj, _, err := br.TransactionalEmailsApi.SendTransacEmail(ctx, body)
	if err != nil {
		if gserr, ok := err.(brevo.GenericSwaggerError); ok {
			if merr, ok := gserr.Model().(brevo.ErrorModel); ok {
				logrus.Errorf("Sending email: API Error: Code %s, Message: %s", merr.Code, merr.Message)
			} else {
				logrus.Errorf("Sending email: API Error decoding error response: %v (body %s)", gserr.Error(), string(gserr.Body()))
			}
		} else {
			logrus.Errorf("Sending Email: %v", err)
		}
		return fmt.Errorf("Error sending email: %w", err)
	}

Result:

Sending email: API Error: Code invalid_parameter, Message: Scheduled date should not be less than current date

@abdorrahmani
Copy link

Hi!

I had the same problem and I sent the email as Scheduled and set its value to time.Now().Add(10 * time.Second) and when using time.Now().Add(5 * time.Second) It gives error 400 again

@ivanovaleksey
Copy link

@jain-raunak @LordPax could you guys please take a look into this?

@gwd
Copy link

gwd commented Jan 13, 2025

FYI I switched to postmarkapp.com as a result of this. The golang package is maintained by someone in the community, but actually is maintained, unlike this package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants