campaignmonitor/createsend-php

ErrorCode 50 - Must supply a valid HTTP Basic Authorization header

Closed this issue · 5 comments

Since some time we get the error

{
  "Code": 50,
  "Message": "Must supply a valid HTTP Basic Authorization header"
}

A similar problem was reported in closed issues #15 and #33
I tried to fire a sample request like shown on getting-started with my own api-key, and I get the same response.

  echo file_get_contents('https://api.createsend.com/api/v3.2/clients.json?pretty=true', false, stream_context_create(
    array('http'=>array(
    'method'=>"GET",
    'ignore_errors'=>true,
    'header'=> "Authorization: Basic ".base64_encode($auth['api_key'].':x')."\r\n"
    ))
  ));

I can ensure that:

  • no proxy or firewall is stripping the Authorization header
  • I have no trailing or leading whitespace in the APIKey string

This errorcode is not listed in API Docs - response-status-codes, but I checked the Authorization that is delivered by you API class and by my exmpla with native php file_get_contents.
Both seem to send a valid Basic auth header, that contains my correct api-key.

Is it possible that there could be a problem with the API-Endpoint or any changes in the auth-methods?

I'm also facing this issue. I've updated to the latest API PHP Wrapper and the problem remains.

@Radon8472 did you get it fixed? If so, can you please share your solution?

If I set $debug_level to CS_REST_LOG_VERBOSE in CS_REST_Clients argument list I get:

13:26:52 - CS_REST_Clients: Creating wrapper for https://api.createsend.com/api/v3.2/
13:26:52 - CS_REST_Clients: Using cURL for transport
13:26:52 - CS_REST_SERIALISATION_get_available: Getting serialiser
13:26:52 - CS_REST_Clients: Using native json serialising
13:26:52 - CS_REST_Clients: Making GET call to: https://api.createsend.com/api/v3.2/clients//lists.json
13:26:52 - CS_REST_CurlTransport: curl+zlib support available. Requesting gzipped response.
13:26:53 - CS_REST_CurlTransport: API Call Info for GET https://api.createsend.com/api/v3.2/clients//lists.json: 0 bytes uploaded. 75 bytes downloaded Total time (seconds): 1.414352
13:26:53 - CS_REST_Clients: Call result:
array (
  'code' => 401,
  'response' => '{"Code":50,"Message":"Must supply a valid HTTP Basic Authorization header"}',
)

@machadoug Yes, after talking to CM support i got the info that they disabled some api codes for security reasons, and that causes that errorcode.

According the API-documentation I would expect such issues should return

{
    "Code": 100,
    "Message": "Invalid API Key"
}

but it seems that this security disabled keys have a different code that is not listed in the docu 🙄

@machadoug today I finally could try it with the new api code.
Now getting clients works, but when I try to get a list I get an error in transport.php.

Can you tell me how I can set the debug-level ?

I'm facing the same issue recently. I have not changed my code implementation, so there must be a change at API level?

Regenerating your API Key should fix the issue.

Hi, I got the same error. We have multiple clients under same account. But for this specific client, I regenerated the API key too. But it did not resolve the issue.

I am using OAuth authentication method. I successfully generated the access code and refresh code. But "Must supply a valid HTTP Basic Authorization header" error appears when I try to get request for subscriber.