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
satheeshrsksatheeshrsk 

Unable to connect API (Hoover's) by using HTTP callouts

Hi,

I am trying to make a callout from APEX to an HTTP endpoint(Hoover's API)  but am receiving the following error:

 
 500, internal server error'.

Here is my Apex class :



global public with sharing class HttpCallout_CLS {

    Public static void sendRequest(){
   
    String API_KEY = 'XXX';
   
    String env;
    env =  '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://applications.dnb.com/webservice/schema/">'+
             '<soapenv:Header>'+
                '<sch:API-KEY>XXX</sch:API-KEY>'+
             '</soapenv:Header>'+
             '<soapenv:Body>'+
               '<sch:FindCompanyByKeywordRequest>'+
                 '<sch:sortDirection>Ascending</sch:sortDirection>'+

                 '<sch:keyword>xyz</sch:keyword>'+

- Hide quoted text -

                 '<sch:searchBy>companyName</sch:searchBy>'+
                 '<sch:returnSearchNavigation>false</sch:returnSearchNavigation>'+
                 '<sch:orderBy xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>'+
                 '<sch:searchNavigation>'+
                   '<sch:employeeSearchNavigation>'+
                   '</sch:employeeSearchNavigation>'+
                   '<sch:ownershipTypeSearchNavigation>'+
                   '</sch:ownershipTypeSearchNavigation>'+
                   '<sch:locationTypeSearchNavigation>'+
                   '</sch:locationTypeSearchNavigation>'+
                   '<sch:salesSearchNavigation>'+
                   '</sch:salesSearchNavigation>'+
                   '<sch:locationSearchNavigation>'+
                     '<sch:countryNavigation>'+
                       '<sch:countryNavigationValue>${#Project#countryNavigationValue}</sch:countryNavigationValue>'+
                       '<sch:stateNavigation>'+
                        '<sch:stateNavigationValue>${#Project#stateNavigationValue}</sch:stateNavigationValue>'+
                        '<sch:cityNavigation>'+
                          '<sch:cityNavigationValue>${#Project#cityNavigationValue}</sch:cityNavigationValue>'+
                        '</sch:cityNavigation>'+
                      '</sch:stateNavigation>'+
                    '</sch:countryNavigation>'+
                  '</sch:locationSearchNavigation>'+
                  '<sch:industrySearchNavigation>'+
                  '</sch:industrySearchNavigation>'+
                '</sch:searchNavigation>'+
              '</sch:FindCompanyByKeywordRequest>'+
            '</soapenv:Body>'+
          '</soapenv:Envelope>';
 
   Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setEndpoint('http://hapi.hoovers.com/HooversAPI-32');
    req.setMethod('POST');
    req.setBody(env);
    req.setTimeout(12000);
   
    Blob headerValue = Blob.valueOf(API_KEY);

    String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
    req.setHeader('Authorization',authorizationHeader);

       
    HTTPResponse res = h.send(req);
    System.debug(res.getBody());
    }
}




  I tried with username and password also, even though i'm facing the same issue. Has anyone experienced anything similar to this?.   Any help must be appreciated.

Thanks Inadvance,
Satheesh
AruAruAruAru

satheeshrsk wrote:

Hi,

I am trying to make a callout from APEX to an HTTP endpoint(Hoover's API)  but am receiving the following error:

 
 500, internal server error'.

Here is my Apex class :



global public with sharing class HttpCallout_CLS {

    Public static void sendRequest(){
   
    String API_KEY = 'XXX';
   
    String env;
    env =  '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://applications.dnb.com/webservice/schema/">'+
             '<soapenv:Header>'+
                '<sch:API-KEY>XXX</sch:API-KEY>'+
             '</soapenv:Header>'+
             '<soapenv:Body>'+
               '<sch:FindCompanyByKeywordRequest>'+
                 '<sch:sortDirection>Ascending</sch:sortDirection>'+

                 '<sch:keyword>xyz</sch:keyword>'+

- Hide quoted text -

                 '<sch:searchBy>companyName</sch:searchBy>'+
                 '<sch:returnSearchNavigation>false</sch:returnSearchNavigation>'+
                 '<sch:orderBy xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>'+
                 '<sch:searchNavigation>'+
                   '<sch:employeeSearchNavigation>'+
                   '</sch:employeeSearchNavigation>'+
                   '<sch:ownershipTypeSearchNavigation>'+
                   '</sch:ownershipTypeSearchNavigation>'+
                   '<sch:locationTypeSearchNavigation>'+
                   '</sch:locationTypeSearchNavigation>'+
                   '<sch:salesSearchNavigation>'+
                   '</sch:salesSearchNavigation>'+
                   '<sch:locationSearchNavigation>'+
                     '<sch:countryNavigation>'+
                       '<sch:countryNavigationValue>${#Project#countryNavigationValue}</sch:countryNavigationValue>'+
                       '<sch:stateNavigation>'+
                        '<sch:stateNavigationValue>${#Project#stateNavigationValue}</sch:stateNavigationValue>'+
                        '<sch:cityNavigation>'+
                          '<sch:cityNavigationValue>${#Project#cityNavigationValue}</sch:cityNavigationValue>'+
                        '</sch:cityNavigation>'+
                      '</sch:stateNavigation>'+
                    '</sch:countryNavigation>'+
                  '</sch:locationSearchNavigation>'+
                  '<sch:industrySearchNavigation>'+
                  '</sch:industrySearchNavigation>'+
                '</sch:searchNavigation>'+
              '</sch:FindCompanyByKeywordRequest>'+
            '</soapenv:Body>'+
          '</soapenv:Envelope>';
 
   Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setEndpoint('http://hapi.hoovers.com/HooversAPI-32');
    req.setMethod('POST');
    req.setBody(env);
    req.setTimeout(12000);
   
    Blob headerValue = Blob.valueOf(API_KEY);

    String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
    req.setHeader('Authorization',authorizationHeader);

       
    HTTPResponse res = h.send(req);
    System.debug(res.getBody());
    }
}




  I tried with username and password also, even though i'm facing the same issue. Has anyone experienced anything similar to this?.   Any help must be appreciated.

Thanks Inadvance,
Satheesh

Hi Satheesh, 

Are you able to resolve this?
I am getting the similar issue,