• How to update / save a blog post using the java api?

    By Christian Hellinger 1 decade ago

    Hi,

     

    I wonder if the blog API is working already?

     

    I am able to get a list of all blogs and read the blog posts, using the java api of the sdk.

    But when I try to create or update a blog post, either I get a NullPointerException or the post isn't updaed.

    The following code works without errors but apparently does nothing:

    BlogPost post = sbcs.getBlogService().getBlogPost(blogHandle, postId);
                    
                    if (null != post){
                        System.out.println("Found post "+post.getTitle()+" ("+post.getAlternateUrl()+")");
                        try{    
                        //Save the post
                            System.out.println("Update blog post");
                            post.setContent("

    blabla "+new Date()+"

    ");
                            post.setTitle(post.getTitle()+" +");
                            sbcs.getBlogService().updateBlogPost(post, blogHandle);
                        }catch(Exception e){
                            e.printStackTrace();
                        }
                    }

     

    I also tried to use the save(String handle) method of the BlogPost, this created an NPE.

    Do I miss something?