One of the line of code was - request += CrmEncodeDecode.CrmXmlEncode(sFetchXml);
I was getting rando error “CrmEncodeDecode is undefined” . CrmEncodeDecode object is a part of global.ashx which was not loading properly. As it was a test app, I was using hard-coded CRMurl and not using “GetGlobalContext().getServerUrl();” to get it.
If you use GetGlobalContext(), it also loads related files as well. For getting CRM config data, I would recommend to use client global context by adding below line of code in your application.