Expand my Community achievements bar.

SOLVED

API Error

Avatar

Level 5

We are slowly killing off other form data sources. In the mean time I am GETting them and putting them into Adobe Campaign. I'm trying to do this by API and the JS activity. But I keep getting this error.

Error 04/29/2018 7:16:17 PM

js2222

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

Here is the full response

04/29/2018 7:27:23 PM {"Code":50,"Message":"Must supply a valid HTTP Basic Authorization header"}

04/29/2018 7:27:23 PM header[Date] => Mon, 30 Apr 2018 00:27:23 GMT

04/29/2018 7:27:23 PM header[Content-Type] => application/json; charset=utf-8

04/29/2018 7:27:23 PM header[Content-Length] => 75

04/29/2018 7:27:23 PM header[Connection] => keep-alive

04/29/2018 7:27:23 PM header[Server] => cm-api-server

04/29/2018 7:27:23 PM header[Www-Authenticate] => Basic realm="api.createsend.com"

04/29/2018 7:27:23 PM header[X-Cache] => MISS

04/29/2018 7:27:23 PM header[X-Edge-Request-Duration] => 1ms

04/29/2018 7:27:23 PM header[X-Edge-Request-Id] => dad91111-64fc-5a48-1914-4911040ec829

04/29/2018 7:27:22 PM --------------Campaign Monitor---------------

Here is my JS

logInfo('--------------Campaign Monitor---------------')

var url = "https://api.createsend.com/api/v3.1/clients.json";

var http = new HttpClientRequest(url);

//Set header type

http.method = "GET";

http.header["Content-Type"] = "application/json";

http.header["Accept"] = "application/json";

http.header["Authorization"] = "myKeyNotYours";

http.method = "Get";

http.execute();

var response = http.response 

for(var i in response.header) 

  logInfo("header[" + i + "] => " + response.header[i])

//pull the response as text.

var httpResponse = http.response.body.toString()

logInfo(httpResponse)

Here are other two other similar issues but I can get their solutions to work for me.

https://github.com/campaignmonitor/createsend-php/issues/15

https://developer.salesforce.com/forums/?id=906F0000000kD7bIAE

I'm not sure what I am doing wrong. Any help would be great.Adobe Campaignamit_krflorentlb

1 Accepted Solution

Avatar

Correct answer by
Level 5

I was able to solve this by using ther term 'Basic' in the auth header.

http.header["Authorization"] = "Basic [myKeyBase64]";

I actually used PostMan to set up the API first, and just re wrote it for AC.

View solution in original post

1 Reply

Avatar

Correct answer by
Level 5

I was able to solve this by using ther term 'Basic' in the auth header.

http.header["Authorization"] = "Basic [myKeyBase64]";

I actually used PostMan to set up the API first, and just re wrote it for AC.