You need to sign in to do that
Don't have an account?
rajesh_y
Unauthorized StatusCode=401
Hi All I wanna get all contacts from constant contact to salesforce the code is 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()); } } but i am getting error like. Unauthorized StatusCode=401 whats wrong in the code All credentials are valid please help me in this area thank you in advace.
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()); } }
Please help me
thank you in advance