Salesforce Integration

Salesforce Callouts troubleshooting using RequestBin

Debug Logs are a powerful tool provided by Salesforce to look at the logs and analyze the error’s (if any) being thrown. It is also used to trace the state of the application flow or view the state of variables, objects at any point of time. It can almost record any database operations, system processes, and errors that occur when executing a transaction or running unit tests. There are various levels of logs you can configure such as FINE, DEBUG, FINEST, etc depending on your need.

Debug Logs are also very useful when it comes to HTTP Callouts as it can provide you the outgoing request parameters/body to confirm the request is correct. But sometimes there could be an issue that you are not receiving a response back from the web service being called – it could be due to an issue with the web service itself, could be an issue with the network from your salesforce instance to the web service endpoint or the request could be not even going out of your Salesforce instance. To troubleshoot – these kinds of issues and to know where the request is getting blocked, you can use a tool available over the internet called as – RequestBin . Instead of sending the request to the actual endpoint, you need to send it to a specific RequestBin URL – which collects your request and displays information accordingly on the browser.

Below are the steps to follow to configure RequestBin for troubleshooting –

a) Open the RequestBin website and click at the ‘Create a RequestBin‘ to generate a specific URL for your test. It is unique per browser per launch/creation. In my case – it generated as below shown.

b) Copy the URL and go to Setup | Security Controls | Remote Site Settings | New Remote Site and paste it and let’s say name it – ‘RequestBin‘ as shown and save.

c) Then in your Apex Callout code where you are using the endpoint, replace the value with the above URL – make sure to comment out and not delete the previous value as you will have to revert it. In my case, I am using the AsyncStockQuoteSoap service and updating it’s endpoint value for the troubleshooting.

d)  Now go ahead and submit your request – if the above setup is correct, you might see some exception on your page – ignore it as it is only for testing purpose. Go to the page where RequestBin is open and refresh the window. You should see few updates on the page – such as from where the request came in, form/post parameters, header info and raw body of the request as shown. If you do not see a request details – it assures that the request is not leaving your Salesforce instance and should check security setup related to allowed IP addresses and posts.

Feel Free to provide your valuable comments or point out any issues or scope of improvement in this post.