Post to orchard blog programmatically

Nov 23, 2010 at 10:52 AM

I want to add post blog programmatically with MetaWeblog by using tools described here.

I can not find Orchard endpoint and it does not clear for me what I have to pass in blogId field in newPost method:

MetaWeblogClient blog = new MetaWeblogClient();
blog.Url = ""; // here?

// here's how you post a new entry...
Post newPost = new Post();
newPost.dateCreated = DateTime.Now;
newPost.title = "Test post from Metablog Api";
newPost.description = "This is the body of the post";
newPost.categories = new string[] { "WCF", "WF" };
blog.newPost("blogid", "username", "password", newPost, true);
// here's how you retrieve the most recent entries...
Post[] posts = blog.getRecentPosts("blogid", "username", "password", 5); // here?
foreach (Post post in posts)

Please help me to solve this issue.
Nov 23, 2010 at 4:46 PM

You could monitor the outgoing traffic from LiveWriter as you publish a post using Fiddler. If that doesn't work, let me know and I'll investigate.

Nov 24, 2010 at 9:38 AM

I was able to connect to the  endpoint - getUsersBlogs and getPost are working but newPost gave "Internal Server Error".

Nov 24, 2010 at 5:20 PM

I'm suspecting that's because you're sending categories in. There is a known bug for this. It's fixed in the current build so if you want to sync to that you might be able to make it work (but other stuff might break, it's work in progress, oh, and it won't give ou a 500 but the categories won't be saved).

Nov 24, 2010 at 6:50 PM

Yep, categories aren’t supported. Only tags are with support implemented in Orchard.Tags. Sebastien’s taxonomy module could probably be updated to support categories J

It shouldn’t be the presence of categories in the post struct that’s causing the problem though. Can you get any more info on the error you’re getting. What are you sending for the blogid? The likely points of failure or either: the method is not supported (“metaWeblog.newPost” is but if something else, like “metaWeblog.getCategories”, is being sent that could cause a problem); authentication failed; or the blogid given wasn’t valid. Of course it could be something else but that’s where I’d start.

Nov 25, 2010 at 7:41 AM

I have no problems with categories but I have to remove

newPost.dateCreated = DateTime.Now;

and change blogid type from string to int everywhere in the library to make it work.

Nov 25, 2010 at 2:48 PM


  1. Categories do not break the logic but do not appear in the posts.
  2. Adding dateCreated field causes "XML response from server is unvalid".
  3. BlogId must be type of int.
  4. wp_slug is working.

I am using CookComputing.XmlRpc and Pluralsight.MetaWeblog projects.

I think I should write some tutorial of how to work with Orchard programmatically.

Mar 16, 2011 at 10:40 PM

Yes, please to a post on working with Orchard programmatically.  I have a Silverlight client that I want to give users the ability to edit Orchard content with, and I'd like to know if that is possible and how?

Mar 16, 2011 at 11:28 PM

From Silverlight, yes, your best bet is probably to implement a MetaWeblog client.

Mar 17, 2011 at 1:13 PM

Just to make sure I understand correctly, a MetaWeblog client would let me manage all content in Orchard, and not just blog content?

Mar 19, 2011 at 12:37 AM

No, only blog contents. It would be fairly easy to add MetaWeblog support to another content type provided it's not too far from the blog or page model but that is not supported out of the box. For other content types, I don't see how that would work as MetaWeblog is fairly specialized.