You need to sign in to do that
Don't have an account?
Shri Raj
REST API Integration Issue. - System.HttpResponse[Status=Service Unavailable, StatusCode=503]
Hello All,
I will try to frame my question in short.
End Goal : REST API Integration from Salesforce to a InHouse Lead Management System(LMS2)
SUCCESS Through Chrome APP
1. All i need to do is retrieve values from LMS2. When i tried to use the Chrome APP 'Advanced Rest Client' and have passed the appropriate URL and Content in XML/TEST format in the form of POST methoed I was able to retrieve the values from LMS2 database.
For EG : If i pass 92126 then i was able to get 'SAN DIEGO' which is correct.
Here is the link (https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo?hl=en-US)for Advanced REST Client.
PROBLEM from Salesforce :
2) When i created this REST class in SAlesforce and tried invoking the End Point then its throwing this error.
System.HttpResponse[Status=Service Unavailable, StatusCode=503]
public with sharing class LmsRestApiIntegration {
//LmsRestApiIntegration.invokeRestAPI()
@future(callout = true)
public static void invokeRestAPI(){
String URL = 'http://pasquote-bfapp.tent.trt.ccc.pri/QuickQuoteWebSvc/QQWebSvc.asmx';
String xmlContent = '';
xmlContent = '<?xml version="1.0" encoding="utf-8"?>';
xmlContent = xmlContent + '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';
xmlContent = xmlContent + '<soap:Body>';
xmlContent = xmlContent + '<GetCityListFromZip xmlns="http://www.ccc.com/irv/quickquote/auto/2006/10/01">';
xmlContent = xmlContent + '<zipcode>92126</zipcode></GetCityListFromZip>';
xmlContent = xmlContent + '</GetCityListFromZip>';
xmlContent = xmlContent + ' </soap:Body>';
xmlContent = xmlContent + '</soap:Envelope>';
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setBody(xmlContent);
req.setHeader('content-type','text/xml');
req.setHeader('content-length', '0');
req.setEndpoint(URL);
req.setHeader('SoapAction', 'http://www.ccc.com//irv/quickquote/auto/2006/10/01/GetCityListFromZip');
req.setMethod('POST');
String response = '' ;
HttpResponse res = h.send(req);
response = res.getBody();
System.debug('Response :'+response);
}
}
Please guide.
Thank You
Shri
I will try to frame my question in short.
End Goal : REST API Integration from Salesforce to a InHouse Lead Management System(LMS2)
SUCCESS Through Chrome APP
1. All i need to do is retrieve values from LMS2. When i tried to use the Chrome APP 'Advanced Rest Client' and have passed the appropriate URL and Content in XML/TEST format in the form of POST methoed I was able to retrieve the values from LMS2 database.
For EG : If i pass 92126 then i was able to get 'SAN DIEGO' which is correct.
Here is the link (https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo?hl=en-US)for Advanced REST Client.
PROBLEM from Salesforce :
2) When i created this REST class in SAlesforce and tried invoking the End Point then its throwing this error.
System.HttpResponse[Status=Service Unavailable, StatusCode=503]
public with sharing class LmsRestApiIntegration {
//LmsRestApiIntegration.invokeRestAPI()
@future(callout = true)
public static void invokeRestAPI(){
String URL = 'http://pasquote-bfapp.tent.trt.ccc.pri/QuickQuoteWebSvc/QQWebSvc.asmx';
String xmlContent = '';
xmlContent = '<?xml version="1.0" encoding="utf-8"?>';
xmlContent = xmlContent + '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';
xmlContent = xmlContent + '<soap:Body>';
xmlContent = xmlContent + '<GetCityListFromZip xmlns="http://www.ccc.com/irv/quickquote/auto/2006/10/01">';
xmlContent = xmlContent + '<zipcode>92126</zipcode></GetCityListFromZip>';
xmlContent = xmlContent + '</GetCityListFromZip>';
xmlContent = xmlContent + ' </soap:Body>';
xmlContent = xmlContent + '</soap:Envelope>';
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setBody(xmlContent);
req.setHeader('content-type','text/xml');
req.setHeader('content-length', '0');
req.setEndpoint(URL);
req.setHeader('SoapAction', 'http://www.ccc.com//irv/quickquote/auto/2006/10/01/GetCityListFromZip');
req.setMethod('POST');
String response = '' ;
HttpResponse res = h.send(req);
response = res.getBody();
System.debug('Response :'+response);
}
}
Please guide.
Thank You
Shri
All Answers
So many answers in so much little time. Much Overwhelmed!!!
Hello James
1. Yes i have added the site into the Remote site settings. But it only considers until here " http://pasquote-bfapp.tent.trt.ccc.pri"
2. This URL is correct since, I have passed the same through Chrome REST API extension. And it was working. http://pasquote-bfapp.tent.trt.ccc.pri/QuickQuoteWebSvc/QQWebSvc.asmx . Since i mentioned its an IN-House .Net Application, It cannot be invoked from an External Website directly. Since the Chrome Extension is a Plugin inside our Network, I have a feeling thats how it worked getting the response back.
3. If i use the same Chrome Extension from my home without connecting through our Office network then it doesnt work. Therfore i think its out Network issues or the Enpoint Application which is not globally available.
Hello Gigi,
1. Yes the End Point is typed 100% correctly. if i paste it in a webbrowser then I'm able to access the page.
Hello Kartik,
1. The WS only accepts text/xml format. Thats the reason I'm sending the xml content.
I also have a feeling that could be the issue. The End Point is not publically hosted. Now, How can a Endpoint be hosted only for Salesforce.com? And also, Before talking to the end point team i want to make sure that i have corrected myself on the Salesforce side.
Thanks
Thanks everyone again!
Whitelisting allows Salesforce to access the resource. The only caveat is that because Salesforce is multi-tenant it means that any instance of Salesforce on the range that you whitelist would have access to your endpoint. If this is not ok, you might want to add some sort of header or sign the request to the call to that identifies your Salesforce instance uniquely from any other instance to validate that the call originated from your Salesforce org.
(I am linking to the article instead of pasting the IP ranges here because these may change in the future).
Thanks (https://www.hindishayariadda.com)
Thanks (https://wordifact.com/jobriya/)