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
Parthiban sfdcParthiban sfdc 

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());
        }

    }

   

}
Pramod_SFDCPramod_SFDC
HI,

Not sure, if you have resolved this, but can you give me the endpoint url and the exact error meeage ?

Regards
Pramod