callback
callback

Reputation: 4122

MailChimp response code 200

I am running the MailChimp subscribe API call. The JSON object sent looks like this:

{  
   "apikey":"someAPIkey-us10",
   "id":"someID",
   "email":{  
      "email":"[email protected]"
   },
   "merge_vars":{  
      "products":[  
         {  
            "name":"prod",
            "url":"https:\/\/www.example.co.uk\/properties\/link\/sub\/res",
            "price":"\u00a3378.00",
            "location":"loc",
            "area":"are"
         }
      ]
   },
   "double_optin":false
}

and the php code that executes the curl object looks like:

$curl = curl_init(SEED_URL);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, $jsonStr);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, 
    array(
        "Accept: application/json",
        "Content-Type: application/json",
        "Content-Length: " . strlen($jsonStr)
    )
);
$response = curl_exec($curl);
var_dump($response);
$responseCode = curl_getinfo ($curl , CURLINFO_HTTP_CODE);
    if ($responseCode !== 201) {
        throw new Exception("post failed with response code " . $responseCode . " " . $jsonStr, 1);
    }

the $response dump is valid and looks like:

"{"email":"[email protected]","euid":"someEUID","leid":"someLEID"}"

However a

post failed with response code 200.

is thrown, and the subscribers list is not being populated in the mailChimp server.

Upvotes: 1

Views: 2173

Answers (1)

PJ Bergeron
PJ Bergeron

Reputation: 2998

HTTP code 200 means that your request was successful. See https://apidocs.mailchimp.com/api/2.0/

You just have to wait a few minutes to see your subscribers list populated.

Upvotes: 1

Related Questions