You need to sign in to do that
Don't have an account?
CallOut Error
Hi all,
i got a bad request error for the following class, so please anyone help me to solve this issue
public class WebServiceCallout {
public void Web1() {
String name='sss';
String username = 'username';
String password = 'password';
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
Blob headerValue = Blob.valueOf(username+':'+password);
String authorizationHeader = 'basic ' + EncodingUtil.base64Encode(headerValue);
req.setHeader('Authorization',authorizationHeader);
req.setHeader('Content-Type','application/json');
req.setEndpoint('https://login.salesforce.com/services/apexrest/Account');
req.setMethod('POST');
req.setBody('name='+name);
try {
res = http.send(req);
system.debug('>>>>>>>>>>>>>>>>'+res.getstatus());
} catch(System.CalloutException e) {
System.debug('Callout error: '+ e);
System.debug(res.toString());
}
}
}
i got a bad request error for the following class, so please anyone help me to solve this issue
public class WebServiceCallout {
public void Web1() {
String name='sss';
String username = 'username';
String password = 'password';
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
Blob headerValue = Blob.valueOf(username+':'+password);
String authorizationHeader = 'basic ' + EncodingUtil.base64Encode(headerValue);
req.setHeader('Authorization',authorizationHeader);
req.setHeader('Content-Type','application/json');
req.setEndpoint('https://login.salesforce.com/services/apexrest/Account');
req.setMethod('POST');
req.setBody('name='+name);
try {
res = http.send(req);
system.debug('>>>>>>>>>>>>>>>>'+res.getstatus());
} catch(System.CalloutException e) {
System.debug('Callout error: '+ e);
System.debug(res.toString());
}
}
}
Not sure, if you have resolved this, but can you give me the endpoint url and the exact error meeage ?
Regards
Pramod