Error Code 50/ Http_status_code 401 : Must supply a valid HTTP Basic..


I am currently trying to pull data from a campaign monitor list.

Here is the php code :
require_once 'campaignmonitor/csrest_lists.php';

$wrap = new CS_REST_Lists($apiKey, $listID);

$result = $wrap->get_active_subscribers(date('Y-m-d', strtotime('-700 days')), 1, 1000, 'email', 'asc');

Then, I have the following error code :

[code]CS_REST_Wrapper_Result Object ( [response] => stdClass Object ( [code] => 50 [Message] => Must supply a valid HTTP Basic Authorization header ) [http_status_code] => 401 )[/code]

I checked 3 times the value of the $apiKey and the $listID parameter.
What am I doing wrong?

Thanks in advance!

Phil Phil, 3 years ago

Hi theobdev,

Check the signature of the CS_REST_Lists constructor, and the way it's used in the sample

If you reverse the order of $apiKey and $listID you'll be fine :)

theobdev, 3 years ago

Thank you Phil, it is now working.

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free