Hi All,
i want to get contacts of constantcontact to salesforce.(integration of constantcontact with salesforce)for this i wrote a class like
public class Constantcontactws{public void invokeExternalWs(){Http h = new Http(); HttpRequest req = new HttpRequest(); final string username = 'ApiKey%Username'; final string password = 'Password'; Blob headerValue = Blob.valueOf(username); String authorizationHeader = 'BASIC ' +EncodingUtil.base64Encode(headerValue); req.setHeader('Authorization',authorizationHeader); 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('POST'); req.setbody('https://api.constantcontact.com/ws/customers/Username/contacts'); req.setEndpoint('http://api.constantcontact.com/ws/customers/joesflowers/lists'); HttpResponse res = h.send(req); system.debug('********'+res.getbody());
}}
By running this class i got an exception like Status=Unauthorized, StatusCode=401 .How to fix this one. any one can u please help me.
Thanks in advance.
I updated your post to hide your username, password and API Key. Please change your password ASAP for security purposes as other people may have seen this and now have access to your account.
Regarding the 401 error, it looks like the problem is that while you're setting the login information for your account, the request endpoint seems to be set to our sample code account, joesflowers. You would correctly get a 401 error in this scenario because you don't have access to joesflowers account.
The holidays have come and gone. For many seasonal businesses, this means the rush of shoppers has decreased as well. Instead of turning off the lights and waiting for spring, make your email marketi...
See Article