Question

I am attempting to post a blog post to a wordpress blog using XMLRPC. Here is the code I am using:

  def post(article)
    my_new_blog_post = {   
     :description => article.article_texts.last.content,   
     :title => article.article_title,   
     :excerpt => '',   
     :categories => [],   
     :post_status => 'publish'   
     }   

    server = XMLRPC::Client.new(url)   

    # Returns the ID of the new post, or fail   
    resp = server.call("metaWeblog.newPost", 0, site_login, site_password , my_new_blog_post)
  end

Everything is created correctly, including the login and password, but for some reason I keep getting a 400 Bad Request error. I logged in on the wordpress site and it worked with the username and password, so I thought maybe there are some incompatibilities with the newest ruby and the XMLRPC client. If so, is there some other method I should be using that would accomplish the same results?

Thanks!

Was it helpful?

Solution

Not sure if this will help anyone, but figured I should put it up here. I just had to call XMLRPC::Client.new2(url) instead. Apparently this other type of client works.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top