ASP.Net API integration with C#

I’ve been playing around with getting my blog to automatically post to when a new post is added (just because I can) and it’s actually very easy to talk to the API. To get any communication going, just create a WebRequest, add authentication, and away you go. The bit of code below reads an XML document of all posts into a string:

HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(“”);
myReq.Credentials = new NetworkCredential(username,password);//Both as strings
HttpWebResponse response = (HttpWebResponse)myReq.GetResponse();
myReq.UserAgent = “K-blog adder”;//Optional
Stream receiveStream = response.GetResponseStream();
StreamReader readStream = new StreamReader (receiveStream, System.Text.Encoding.UTF8);
string deliciousResponse = readStream.ReadToEnd();

And now all my blog posts are linked on There are a few problems linked with having to use the API sparingly (otherwise they start sending 503 headers back) so you can’t post too much at once, but it works as well as it’s going to.

Leave a Reply

Your email address will not be published. Required fields are marked *