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.

This entry was posted in Programming. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s