Reputation: 441
I am simply trying to add a new member to a MailChimp list. But I keep getting the following error and can't quite understand why:
type: http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/
title: Invalid Resource
status: 400
detail: The resource submitted could not be validated. For field-specific details, see the 'errors' array.
instance:
errors:
0:
field:
message: Schema describes object, NULL found instead
This is quite odd because I am sending the exact object in the body as detailed in the exampled from the docs:
{"email_address":"urist.mcvankab+3@freddiesjokes.com", "status":"subscribed"}
I have tried the call in Postman as well the MailChimp Playground. Am I omitting something in the JSON here?
Upvotes: 9
Views: 16114
Reputation: 175
Even if the merge_fields
aren't marked as required they are, to bypass the requirement you can pass the query parameter { skipMergeValidation: true }
as the third parameter in the addListMember
request. You can see the doc and the implementation below:
this.addListMember = function(listId, body, opts) {
return this.addListMemberWithHttpInfo(listId, body, opts)
.then(function(response_and_data) {
return response_and_data.data;
});
}
Upvotes: 0
Reputation: 91
i was working with node application and this worked for me, instead of using
url: 'https://blabla.api.mailchimp.com/3.0/lists/{list_id}/members'
try this JavaScript object:
const data = {
members:[{
email_address: email,
status: "subscribed",
merge_fields: {
FNAME : firstName,
LNAME : lastName }
}]
};
and use url:
url: "https://us7.api.mailchimp.com/3.0/lists/{list_id}"
Note: you must convert JavaScript object to JSON
Upvotes: 0
Reputation: 378
So I was stuck as well, turns out you need to have "merge_fields". Make it an empty object,
{
"email_address": "blahblar@blarblah.com",
"status": "subscribed",
"merge_fields": {}
}
Upvotes: 13
Reputation: 59
The problem is in url. You must have members on the url end:
url: 'https://blabla.api.mailchimp.com/3.0/lists/blabla/members',
Upvotes: 2
Reputation: 1297
Make sure you encode your post data as json. For example in python:
import requests
import json
data = {
"email_address": "test_email@gmail.com",
"status": "subscribed",
"merge_fields": {}
}
result = requests.post(<YOUR URL>, auth=<YOUR AUTH CREDS>, data=json.dumps(data))
Upvotes: 2