Home CookComputing.XmlRpc.XmlRpcServerException: 'Origin Error' with WordPress Sharp
Reply: 0

CookComputing.XmlRpc.XmlRpcServerException: 'Origin Error' with WordPress Sharp

user2173
1#
user2173 Published in June 21, 2018, 8:43 am

When I try to get the list of my blog post via WordPress Sharp, I get an "Origin Error" (CookComputing.XmlRpc.XmlRpcServerException).

What is it and how can I solve the problem, please?

This is my code:

Main class

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var wordPressConfigData = new WordPressConfigData()
            {
                WordPressBlogUrl = "http://example.com",              
                WordPressBlogUsername = "user",  
                WordPressBlogPassword = "password"           
            };

            var wordPressService = new WordPressService(wordPressConfigData);
            wordPressService.PublishOnBlog("test", "this is just a test");
        } 
    }
}

Service Class

namespace ConsoleApp1
{
    public class WordPressService
    {
        public WordPressSiteConfig Config { get; set; }

        public WordPressService(WordPressConfigData configData)
        {
            Config = new WordPressSiteConfig
            {
                BaseUrl = configData.WordPressBlogUrl,
                BlogId = 1,
                Username = configData.WordPressBlogUsername,
                Password = configData.WordPressBlogPassword
            };
        }

        public void PublishOnBlog(String title, String content)
        {
            var post = new Post
            {
                PostType = "post",
                Title = title,
                Content = content,
                PublishDateTime = DateTime.Now,
                Status = "publish"
            };

            using (var client = new WordPressClient(this.Config))
            {
                var filter = new PostFilter()
                {
                    Number = 3,
                    PostType = WordPressSharp.Constants.PostType.Post,
                    PostStatus = WordPressSharp.Constants.PostStatus.Published
                };
                var posts = client.GetPosts(filter);
            }
        }
    }
}

Something about the error I get:

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.322884 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO