mailjet / mailjet-apiv3-go

[API v3] Official Mailjet API v3 Go wrapper
https://dev.mailjet.com
MIT License
87 stars 32 forks source link

Listrecipient POST Request returns "Unexpected server response code: 400" #110

Open vdemcak opened 1 month ago

vdemcak commented 1 month ago

The following code returns an error Unexpected server response code: 400: Object properties invalid (MJ08 Property Contact is invalid: MJ03 A non-empty value is required) when trying to add a recipient to a list.

Here is the code I'm using. It's pretty much identical to the API docs.

import (
    "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
)

var data []resources.Listrecipient
mr := &mailjet.Request{
  Resource: "listrecipient",
}
fmr := &mailjet.FullRequest{
  Info: mr,
  Payload: &resources.Listrecipient{
    ContactALT: "foo@example.org",
    ListID:     12345678,
  },
}
err := mailjetClient.Post(fmr, &data)
if err != nil {
  fmt.Println(err)
}
vtopc commented 4 days ago

Please try to use the github.com/mailjet/mailjet-apiv3-go/v4 instead.

https://github.com/mailjet/mailjet-apiv3-go?tab=readme-ov-file#installation