Hi,
I am developing a web service to integrate QuickBooks data with a CRM using C#.
CRM API exposes a method to get data from CRM.
I am calling the method to get the data from CRM inside back ground worker and doing some other stuff in the fore ground. Below is the code i have written to accomplish the task
public DataTable GetZohoAccountRecords(string zohoTicket)
{
DataTable dtZohoAccount = new DataTable();
string apiKey = ConfigurationManager.AppSettings["ApiKey"].ToString();
string accountURL = ConfigurationManager.AppSettings["GetAccountURL"].ToString() + zohoTicket + "&apikey=" + apiKey;
gWebRequest = (HttpWebRequest)GetWebRequest(new Uri(accountURL));
gWebRequest.Method = "GET";
//------For getting the Web Response---------
gWebResponse = (HttpWebResponse)gWebRequest.GetResponse();
Stream responseStream = gWebResponse.GetResponseStream();
Stream Reader streamReader = new StreamReader(responseStream);
zohoResponse = streamReader.ReadToEnd();
}
protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest webRequest = null;
try
{
webRequest = (HttpWebRequest)base.GetWebRequest(uri);
webRequest.KeepAlive = false;
//webRequest.ProtocolVersion = HttpVersion.Version10;
}
catch (Exception ex)
{
gQbws.WriteToLogFile("Exception in overriding GetWebRequest\t" + ex.ToString());
}
return webRequest;
}
I am getting System.Net.WebException: The request was aborted: The request was canceled. at System.Net.HttpWebRequest.GetResponse() while trying to get records from CRM.
Can anyone please tell me why I am getting this exception and what do I do to fix this exception.
Any help would be highly appeciated.
thanks
tanmayee
Loading
Master BillaPosted Aug 12, 2009, 1:05 PM
I have a quick question , how do you get the token to attached with your url?
is it given by the CRM when you a re login to CRM using username and password.
could you give then quick book CRM url, i will work for you and give the code.
thank you
tanmayee sahooPosted Aug 12, 2009, 7:42 AM
So I do n't think that it is because of url I am getting WebException. Can you please tell me what else could be the reason.
thanks
tanmayee
Master BillaPosted Aug 12, 2009, 6:14 AM
yes, but he sending Key and token , so when you are access the CRM we don't need set
Roei BarPosted Aug 12, 2009, 5:59 AM
here is a sample code with an Option To pass Credentials
Master BillaPosted Aug 12, 2009, 5:08 AM
there first and most reason is your key(token not valid) to access the CRM.
2. Please check the url is correct after concatenate key
string accountURL = ConfigurationManager.AppSettings["GetAccountURL"].ToString() + zohoTicket + "&apikey=" + apiKey;
i think may be one & sign is missing before the the zohoTicket.(i think )
3.Please ping to normal to that server is working.
if those are OK fine then it will work
Note:Please verify you are composing acceptablt format to get the response from the CRM
Thank you