I have written a c# app to migrate my data from Blinksale to Freeagent. This is all working fine and I am making the various web service calls suitably however when I run the process as a batch it gets to the 3rd invoice on the import and times out. On a like like
Stream dataStream = request.GetRequestStream ();
Now I’ve contacted the API provider (Freeagent), who are very good, and they have checked the logs, and the first 2 attempts are made (which consist of 3 individual calls each) but there is no sign of the 3rd request. This would make it about the 8th request to this web service, but there may have been quite a few using similar code prior to this to get the data.
Therefore I am assuming it is something to do with my .net code.
Its hard for me to share any snippets as there is so much going on, but essentially I am doing the same thing as this multiple times.
N.B. I have checked and it isnt the data in the 3rd request thats in question (I skipped it with same result)
// Create a request using a URL that can receive a post.
WebRequest request = WebRequest.Create ("http://www.contoso.com/PostAccepter.aspx ");
// Set the Method property of the request to POST.
request.Method = "POST";
// Create POST data and convert it to a byte array.
string postData = "This is a test that posts this string to a Web server.";
byte[] byteArray = Encoding.UTF8.GetBytes (postData);
// Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded";
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;
// Get the request stream.
Stream dataStream = request.GetRequestStream ();
// Write the data to the request stream.
dataStream.Write (byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close ();
// Get the response.
WebResponse response = request.GetResponse ();
// Display the status.
Console.WriteLine (((HttpWebResponse)response).StatusDescription);
// Get the stream containing content returned by the server.
dataStream = response.GetResponseStream ();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader (dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd ();
// Display the content.
Console.WriteLine (responseFromServer);
// Clean up the streams.
reader.Close ();
dataStream.Close ();
response.Close ();
Wow, so much code. Try this:
If this doesn’t work it’s a network and/or server problem. You could also activate logs on the client by putting the following in your app/web.config to know exactly what’s happening on the HTTP stack: