You need to sign in to do that
Don't have an account?
rajesh_y
webservice call outs urgent please help me
public class lll { public string errormessage; @future (callout=true) public static void Login() { //ErrorMessage=''; final string baseUrl = 'http://dskvapconsultancyservices.createsend.com/'; final string username = '05b88f78dfc4f00ce93553a79be93d04'; final string password = 'rajesh12'; string apikey='05b88f78dfc4f00ce93553a79be93d04'; Blob headerValue = Blob.valueOf(username + ':' + password); String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue); //req.setHeader('Host','http://api.createsend.com'); //req.setHeader('Content-length', '1753' ); // req.setHeader('Content-Type', 'text/xml;charset=UTF-8'); //req.setHeader('Authorization',authorizationHeader); //req.setHeader('content-type', 'text/xml;charset=utf-8'); //req.setHeader('Content-Length','1024'); //req.setHeader('Host','http://dskvapconsultancyservices.createsend.com/'); //req.setHeader('Connection','keep-alive'); string body1='<?xml version="1.0" encoding="utf-8"?>'; body1+='<Clients> '; body1+='<ApiKey>05b88f78dfc4f00ce93553a79be93d04</ApiKey>'; /*body1+='<AccessDetails>'; body1+='<Username>05b88f78dfc4f00ce93553a79be93d04</Username>'; body1+='<AccessLevel>23</AccessLevel>'; body1+='</AccessDetails>'; body1+='<CompanyName>My Company</CompanyName>'; body1+='<ContactName>John</ContactName>'; body1+='<EmailAddress>john@example.com</EmailAddress>'; body1+='<Country>Australia</Country>'; body1+='<TimeZone>(GMT+10:00) Canberra, Melbourne, Sydney</TimeZone>';*/ body1+='</Clients>'; Http h = new Http(); HttpRequest req = new HttpRequest(); req.setMethod('GET'); req.setBody(body1); //req.setEndpoint(baseUrl + '?loginType=&un='+username+'&pw='+password); //req.setEndpoint('http://api.createsend.com/05b88f78dfc4f00ce93553a79be93d04/v3/clients/clients.xml'); req.setEndPoint('http://api.createsend.com/api/v3/clients.xml'); //req.setbody('http://api.createsend.com/api/v3/clients.xml'); HttpResponse res = h.send(req); //req.setEndpoint(baseUrl + 'apex/UploadFile_DifferentOrg'); //res = h.send(req); system.debug('********'+res.getbody()); if (res.getBody().indexOf('success=true')>-1) { system.debug('Success'); } } }
Hi i am trying the above code to get details of clients which are in campaign monitor
but i am getting following error
10:55:01.657 (657169000)|USER_DEBUG|[52]|DEBUG|********<?xml version="1.0" encoding="utf-8"?><Result><Code>50</Code><Message>Must supply a valid HTTP Basic Authorization header</Message></Result>
|[48]|System.HttpResponse[Status=Unauthorized, StatusCode=401]
what should i do get output by using by using above code
can you please give the details regarding this
please help me with modify the above code if possible.
thank you in advance..
did you set the remote site settings to the requested URL?.. like you have to give the request URL in the remote site settings..
yes
generally 401 error comes if it is not Authenticated.. in your code you are not sending the password in the request.. i think so. check it out once...
HI thank you for your co opetation
now i am getting error like
Fields in error: client
Failed to deserialize your request.
Please check the documentation and try again.
please help me