Skip to main content
I have a webservice which is giving me a callout error. I need to check the endpoint for the webservice is giving a response or not. I have used Httprequest but i am not able to get any response

 

public class AuthCallout {

 

public void basicAuthCallout(){

 

HttpRequest req = new HttpRequest();

 

req.setEndpoint('https://sf.mhsgw.com.au:9501/ServicesHub/ServiceInterfaces/InForce/RetrievePaymentHistoryService');

 

req.setMethod('GET');

 

// Specify the required user name and password to access the endpoint

 

// As well as the header and header information

 

String username = 'myname';

 

String password = 'mypwd';

 

Blob headerValue = Blob.valueOf(username + ':' + password);

 

String authorizationHeader = 'BASIC ' +

 

EncodingUtil.base64Encode(headerValue);

 

req.setHeader('Authorization', authorizationHeader);

 

// Create a new http object to send the request object

 

// A response object is generated as a result of the request

 

Http http = new Http();

 

HTTPResponse res = http.send(req);

 

System.debug(res.getBody());

 

}

 

}
3 answers
  1. May 23, 2014, 10:27 AM
    You can copy the exact URL you are building in your Apex class (use a system.debug() statement so you know you get the exact URL) and then paste that into a browser address bar.   The results or error code will be displayed in the browser.
0/9000