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

How to get the API error message #38

Open
Renrhaf opened this issue May 26, 2023 · 1 comment
Open

How to get the API error message #38

Renrhaf opened this issue May 26, 2023 · 1 comment

Comments

@Renrhaf
Copy link

Renrhaf commented May 26, 2023

Hi !

When working with this API, I'm facing difficulties getting the Sendinblue API error message.

	result, resp, err := sib.TransactionalEmailsApi.SendTransacEmail(ctx, sendinblueMail)
	if err != nil {
		log.Println("Error when calling TransactionalEmailsApi->SendTransacEmail:", err.Error())
		return c.Status(resp.StatusCode).SendString(err.Error())
	}

I'm only getting the generic error message :
2023/05/26 09:42:05 Error when calling TransactionalEmailsApi->SendTransacEmail: 400 Bad Request

When I want to get the specific message like :

{
  "code": "invalid_parameter",
  "message": "File extension mismatch in 'url' & 'name' passed in the request"
}

How to get that from the err variable, since the response object body has already been read and closed, we can not extract it again.
Thank you

@manjurulhoque
Copy link

You can do that by following below code:

image

(not able to paste the code)

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

2 participants