+ Start a Discussion
Abraham kumar 4Abraham kumar 4 

Status=Bad Request, StatusCode=400

Hi All,

I am getting this error on call out to the external database. Im sending data to external databse, Please help getting below error in debug log.
System.HttpResponse[Status=Bad Request, StatusCode=400]

Attached portion of code below:-
public class WebServiceCallout {

    @future (callout=true)
    public static void sendNotification(string Id,string Email,string First_Name,string Last_Name,string phone,string Title,string Account_name,string con_status) {
conweb cont=new conweb(Id,Email,First_Name,Last_Name,Phone,Title,Account_name,con_status);
list<conweb> conwebs=new list<conweb>();
conwebs.add(cont);
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
req.setTimeout(2000); // timeout in milliseconds
        req.setEndpoint('https://www.ext1234/api/user');
        req.setMethod('POST');
        req.setHeader('Content-Type','application/json');
        req.setHeader('Authorization','dasdsadee23442342r');
       req.setBody(JSON.serialize(conwebs[0]));
   try {
            if(!Test.isRunningTest())
                res = http.send(req);
        } catch(System.CalloutException e) {
            System.debug('Callout error: '+ e);
            System.debug(res.toString());
        }

    }
Please help. 

Thanks
Abraham

 
ShashankShashank (Salesforce Developers) 
Could you please let me know if you are still facing this issue?