node-mailchimp
node-mailchimp copied to clipboard
Why Is Count Parameter Ignored For GETs In A Batch?
Each of the following returns more than 10 members, as expected:
mailchimp.request({method:'GET',path:`/list/${list_id}/segments/${segment_id}/members`, query: {count: 1000}})....;
//or
mailchimp.get(`/lists/${list_id}/segments/${segment_id}/members?count=1000`)....;
However, the following only returns at most 10 segment members, per segment even though total_items is greater than 10:
mailchimp.batch([
{method:'GET',path:`/lists/${list_id}/segments/${segment_id_1}/members`, query: {count:1000}},
{method:'GET',path:`/lists/${list_id}/segments/${segment_id_2}/members`, query: {count:1000}},
{method:'GET',path:`/lists/${list_id}/segments/${segment_id_3}/members`, query: {count:1000}},
{method:'GET',path:`/lists/${list_id}/segments/${segment_id_4}/members`, query: {count:1000}},
{method:'GET',path:`/lists/${list_id}/segments/${segment_id_5}/members`, query: {count:1000}}
])....;
Even when count is set to a value lower than 10, each still returns 10 items.
It appears that count is ignored altogether. Not so with other parameters such as:
include_cleaned
include_unsubscribed
Why is count being ignored?
See No More than 10 Segment Members in A Batch Call with mailchimp-api-v3
This is also happening for the /growth-history API call e.g when calling
const res: GrowthHistoryResponse = await mailchimpClient.get(
`/lists/${process.env.MAILCHIMP_LIST_ID}/growth-history`,
'count=10',
);
The result is
{
history: [],
list_id: 'list_id',
total_items: 0,
_links: [
{
rel: 'self',
href: 'https://us14.api.mailchimp.com/3.0/lists/list_id/growth-history',
method: 'GET',
targetSchema: 'https://us14.api.mailchimp.com/schema/3.0/Definitions/Lists/Growth/CollectionResponse.json',
schema: 'https://us14.api.mailchimp.com/schema/3.0/Paths/Lists/Growth/Collection.json'
},
{
rel: 'parent',
href: 'https://us14.api.mailchimp.com/3.0/lists/list_id/',
method: 'GET',
targetSchema: 'https://us14.api.mailchimp.com/schema/3.0/Definitions/Lists/Response.json'
}
],
statusCode: 200
}
Whenever passing query params it's not working but when appending with the path then it works
const res: GrowthHistoryResponse = await mailchimpClient.get(
`/lists/${process.env.MAILCHIMP_LIST_ID}/growth-history?count=12`,
);
Even using
const res: GrowthHistoryResponse = await mailchimpClient.get(
{
path: `/lists/${process.env.MAILCHIMP_LIST_ID}/growth-history`,
query: params.toString(),
},
);
returns empty result
{
"history": [],
"list_id": "list_id",
"total_items": 0,
"_links": [
{
"rel": "self",
"href": "https://us14.api.mailchimp.com/3.0/lists/list_id/growth-history",
"method": "GET",
"targetSchema": "https://us14.api.mailchimp.com/schema/3.0/Definitions/Lists/Growth/CollectionResponse.json",
"schema": "https://us14.api.mailchimp.com/schema/3.0/Paths/Lists/Growth/Collection.json"
},
{
"rel": "parent",
"href": "https://us14.api.mailchimp.com/3.0/lists/list_id/",
"method": "GET",
"targetSchema": "https://us14.api.mailchimp.com/schema/3.0/Definitions/Lists/Response.json"
}
],
"statusCode": 200
}