function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
rajesh_yrajesh_y 

Status=Unauthorized, StatusCode=401 An Authentication object was not found in the SecurityContext

 
public class constantcontact 
{
public void conlist()
{
Http h = new Http();
    HttpRequest req = new HttpRequest();
  final string username = '54149b86-22eb-496b-a326-132dfa9f3786%rajesh_y'; 
        final string password = 'Dskvap123';
        Blob headerValue = Blob.valueOf(username);
     String authorizationHeader = 'BASIC ' +EncodingUtil.base64Encode(headerValue);
     //String authorizationHeader =username+':'+password;
     req.setHeader('Authorization',authorizationHeader);
      //req.setHeader('Content-length', '1753' );
     req.setHeader('Host','https://api.constantcontact.com/ws/customers//contacts/1');
    req.setHeader('Connection','keep-alive');
    req.setHeader('Content-Type', 'application/atom+xml');
     req.setMethod('GET');
      req.setbody('https://api.constantcontact.com/ws/customers/rajesh_y/contacts');
      req.setEndpoint('http://api.constantcontact.com/ws/customers/joesflowers/lists');
      HttpResponse res = h.send(req);
      system.debug('********'+res.getbody());

}
}

 This code for getting all contacts from constantcontact  to salesforce through http callouts

 

But i am getting error like 

An Authentication object was not found in the SecurityContext

Status=Unauthorized, StatusCode=401

 

All credential are valid 

whats problem in my code please help me

 

 

thank you in advance

 

rajesh

dkadordkador

That error is coming from the server you're making your request to.  There's not much we can do to help.