PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, September 6, 2022

[FIXED] How filter an http response with MailChimp API V3?

 September 06, 2022     javascript, mailchimp, mailchimp-api-v3.0, node.js     No comments   

Issue

How filter a http response with MailChimp API V3 ? I'm working in NodeJS. I'm trying to filter the response of my "GET" request in MailChimp API.

​

Here my snippet.js :

​

var getList ="https://us18.api.mailchimp.com/3.0/lists/6b3d443365/members"  

request({
    url: getList,
    method: 'GET',
    headers: {
        'Content-Type': 'application/json',
        'Authorization': 'apikey ' + password
    },
    fields: ["id"], // I have also tried: "Fields"
}, function(err, res, body) {
    if (err) {
        return console.log("err:", err)
    }
    console.log("connection succeed");
    console.log("res: ", body)
});

​

I have tried also :

​

1-

fields:["members.id", "members.email_adress"]

​

2-

fields:"id"

​

res : BIG BUNCH of data

​

all my tentative fails, my console returns me a big bunch with all the data in. I want to filter it but I don't have a clue how to make it. The documentation affirm :

​

Query string parameters

fields:

Type: Array

Title: Fields

Read only: false

A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation.

It seems to me I have followed the notice, so, what's going wrong ?


Solution

The documentation does in fact say that the 'fields' parameter is

A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation.

https://mailchimp.com/developer/reference/automation/

The key information that is missing is that you need to prefix each field with a (redundant) reference to the root object.

/3.0/automations?fields=automations.id,automations.settings.title


Answered By - Dan
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing