phpmailchimpphp-curlmailchimp-api-v3.0

Mailchimp list created with API not available to API, but is in web admin view


I am using the MailChimp API and creating a list, and adding users to it


The process is as follows (cURL connections)

first I get the lists (no data sent with the GET request)

GET: https://{DC}.api.mailchimp.com/3.0/lists

then I query the list to see if the one I need is there with a search of the array returned and fetch the ID if it exists

If it does not exit I add a list (generating a ID in the return value)

POST: https://{DC}.api.mailchimp.com/3.0/lists

I then take that list ID (either existing or newly created one) and add my subscriber

POST: https://{DC}.api.mailchimp.com/3.0/lists/{listId}/members

All of this works

I can view the list in the MailChimp web admin and see the users, I can send emails and add / remove tags

I CANNOT see this list using the API though, when I run the first request to GET the lists again, the new list is not part of that returned result, so I end up making the list again


is there a delay before a created list is available to the API, is there a request I can make that will force it to update and make the newly created list available to me immediately via the API?

If I use the list ID directly in a cURL request it works, even if the API does not return it with a /lists/ GET request


Solution

  • API docs for the list method say,

    count: The number of records to return. Default value is 10. Maximum value is 1000

    If you are not adding any additional parameters to your API call, you would only get the first 10 items.

    So you'll have to specify count with your query, and if you have more than a 1,000 lists, you'd also need to use offset, to implement pagination through the records - https://mailchimp.com/developer/marketing/docs/methods-parameters/#pagination