I am using C# to create a GUI app. It features the ability to upload an snapshot XML feed file to a BB server via SIS functionality. I have successfully used cURL to do this via automated shell scripts but would like to know how do achieve the same results via C#.
I have produced the code below, but it seems to work intermittently. BB doesn't provide useful error responses which makes it hard to debug. I haven't provided all the peripheral class definitions (BBServerResponse,BBCxnDetails) but they are simple containers and you can probably guess what they hold. Note the comment (in red). Only HTTP v1.0 seems to work, at all.
Any hints would be appreciated!
public BBServerResponse UploadFeed(BBCxnDetails bcd)
BBServerResponse resp = new BBServerResponse("Error", HttpStatusCode.InternalServerError);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(bcd.locator);
req.Method = "POST";
req.ContentType = "text/xml";
// Using HTTP v1.0 seems to be important for Blackboard.
req.ProtocolVersion = HttpVersion.Version10;
req.KeepAlive = true;
req.Credentials = new NetworkCredential(bcd.userName, bcd.password);
using (var sw = new StreamWriter(req.GetRequestStream()))
using (var response = req.GetResponse())
using (var sr = new StreamReader(response.GetResponseStream()))
resp = new BBServerResponse(sr.ReadToEnd(), ((HttpWebResponse)response).StatusCode);
if (((HttpWebResponse)response).StatusCode == HttpStatusCode.OK)
catch (Exception ex)
resp = new BBServerResponse(ex.Message.ToString(), HttpStatusCode.InternalServerError);