Closed wilburx9 closed 1 year ago
The implementation of the subscriber creation function doesn't comply with the REST API docs.
In the linked doc, only the email is required and the groups is an array of group ids. However, this call:
email
groups
subscriber := &mailerlite.Subscriber{ Email: "example@example.com", Groups: []mailerlite.Group{{ID: "12345"}}, } client.Subscriber.Create(ctx, subscriber)
Fails with:
POST https://connect.mailerlite.com/api/subscribers: 422 Must be a valid object (and 1 more error) map[fields:[Must be a valid object] groups.0:[The groups.0 must be a number.]]
This is because the whole Subscriber struct is being marshalled and sent along with the request.
Subscriber
For now, I have resorted to calling the endpoint directly.
The implementation of the subscriber creation function doesn't comply with the REST API docs.
In the linked doc, only the
email
is required and thegroups
is an array of group ids. However, this call:Fails with:
This is because the whole
Subscriber
struct is being marshalled and sent along with the request.For now, I have resorted to calling the endpoint directly.