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
king kpking kp 

Throwing the Error is Internal Server Error,Status Code :500 Httpreponse

Hi Friends ,

I have to Integrate Salesforce to External Services 

Throwing the Error Is "Internal Server Error",Status Code :500 " Htttpresponse

External Services Has asking the JSON Format  in this Place Creating the XML Format How To resolve this Could Please Help me.



global class ResponseclsforFIC{
@future(callout=true)
    public static void Responsefrom3rdparty(string syncid){
    try{
      String endPointURL = 'https://cacf-test.crm.us2.oraclecloud.com/crmCommonApi/resources/latest/accounts';
      String userName = 'kullayappa.adapala@config-consultants.com';
      String password = 'Kull@i12345';
      
      // Specify the required user name and password to access the endpoint 
      // As well as the header and header information 
      Blob headerValue = Blob.valueOf(userName + ':' + password);
      String authorizationHeader = 'BASIC ' +EncodingUtil.base64Encode(headerValue);

        DOM.Document resDoc = new DOM.Document();        
            // Send the request
        HttpRequest req = new HttpRequest();   
     //   req.setTimeout(120000);         
        req.setMethod('POST'); 
        req.setEndpoint(endPointURL);
        req.setHeader('Authorization', authorizationHeader);
        sfdcFICxmlcreator genrate = new sfdcFICxmlcreator();
        String xml = genrate.xmlgenrate(syncid);
        req.setHeader('content-type', 'application/vnd.oracle.adf.resourceitem+json; charset=utf-8');
        req.setBody(xml);
        
         System.Debug('......... Body ...........'+xml);
        Http http = new Http();
          
       Transient HttpResponse res = new HttpResponse();
        res = http.send(req); 
          //HttpResponse res = http.send(request);  
           res = http.send(req); 
        system.debug('res.......'+res.getbody());
        Contact sfintegrate = new Contact();
       
        sfintegrate.Accountid=syncid;
        sfintegrate.LastName='ramgopalvarma';
        sfintegrate.Request_Status__c=res.getStatus();
         sfintegrate.Status_Code__c=string.valueof(res.getStatusCode());
         
         system.debug('>>>>>>>>>>>'+syncid);
         system.debug('????????????'+string.valueof(res.getStatusCode()));
         if(sfintegrate.Status_Code__c!='200'){
         sfintegrate.FIC_response__c=res.getbody();
         }
         sfintegrate.Execution_time__c=string.valueof(System.now());
         sfintegrate.Request_Body__c=xml;
         insert sfintegrate ;
      }catch(Exception e){
      System.debug('Error::'+e.getMessage());
    }
  }
 }


Thanks
kullayappa
Pruthvi KankunthalaPruthvi Kankunthala
Open your URL it through normal IE . I think that URL will be prohibited..and restricted that's why it occurs. Also, you have to get registered the endpoint URL in the Remote Site Settings whitelist. 
 
king kpking kp
Hi Pruthvi Kankunthala,

Thanks For your Reply now Throwing the Error Is: Bad Request And Status COde:400
User-added image

And
{
"attributes" : { "type" : "Account", "url" : "/services/data/v37.0/sobjects/Account/0012800000mKa3SAAS" },
"OraganizationName__c" : "kullai",
"Rating" : "Hot",
"Type" : "Prospect",
"Id" : "0012800000mKa3SAAS"

This is the i have to Creating the JSON Format.But External Services Showing the This Type Of format

Content-Type: { "OrganizationName": "Pinnacle Inc",
"Type": "ZCA_CUSTOMER",
"PrimaryAddress": [{ "AddressLine1": "500 oracle parkway",
"City": "Redwood Shores",
"State": "CA",
"Country": "US" }] }



  please Help Me Pruthvi Kankunthala