SpamassRules should be a string for Message
jooola opened this issue · 3 comments
While working with the https://api.mailjet.com/v3/REST/message endpoint, I faced the following issue:
Error decoding API response: json: cannot unmarshal string into Go struct field Message.Data.SpamassRules of type []resources.SpamAssassinRule
It seems like the SpamAssassinRule should either be a string or an array/object, but the client doesn't seem to be consistent with the API.
Since the API is the source of truth I prefer not proposing a PR.
Hey there, I'm facing the exact same issue calling the message endpoint. Is there any update ?
The API documentation states SpamassRules
is a string :
https://dev.mailjet.com/email/reference/messages/#v3_get_message_message_ID
The source code states it's a slice of struct :
package resources
type Message struct {
...
SpamassRules []SpamAssassinRule `json:",omitempty"`
...
}
A simple workaround before a fix is provided :
- var resp []resources.Message
+ var resp []struct {
+ resources.Message
+ SpamassRules string `json:",omitempty"`
+ }
err := mailjetClient.Get(&mailjet.Request{
Resource: "message",
ID: id,
}, &resp)