Rest API with C# failing

  • Unknown's avatar

    I need to use WordPress PCL library consuming the REST API to manage WordPress hosted blogs. The blog is hosted on WordPress.com. The following is the C# code. isValidToken is always returning false.

    Also if I put the below code in an async method then w.RequestJWToken does not wait in breakpoint even if I have an await method for the same.

    Can some one help in what is the problem?

    try
    {
    WordPressClient w = new WordPressClient(“https://public-api.wordpress.com/wp/v2/sites/wpblog.wordpress.com”);
    w.RequestJWToken(“wpusername”, “wppassword”);
    var isValidToken = w.IsValidJWToken().GetAwaiter().GetResult();
    if (isValidToken)
    {
    Post post = new Post();
    post.Title = new Title(“Welcome to WP Blog through WordPress PCL/C#”);
    post.Content = new Content(“This is a text content”);
    post.Date = DateTime.Now;
    w.Posts.Create(post);
    }
    }
    catch (Exception WordPressException)
    {
    Console.WriteLine(WordPressException.Message);
    }

  • Hi there,

    For help with the WordPress.com REST API, please use the form at https://developer.wordpress.com/contact/

    I’m afraid we’re not able to provide developer-level support, including support for using the API, here in the public support forums. These forums provide support for end-users of free sites, and neither our forums staff nor our volunteer community are developers.

  • The topic ‘Rest API with C# failing’ is closed to new replies.