Skip to content

How to get the API error message #38

@Renrhaf

Description

@Renrhaf

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions