Getting exception while adding comments in blogpost programatically

Community Server 2008

Find answers, post questions, and collaborate with other Telligent Community Server v2008.x users.

Getting exception while adding comments in blogpost programatically

Not Answered This question is not answered

Hi,

I am try to add comments in blogpost programatically using below C# code

-----------------------------------------------------------------------

BlogsService service = new BlogsService(siteUrl, username, apiKey);

List<BlogPost> posts = service.GetBlogPosts(blog.Id);

BlogPost post = posts[0];

BlogPostComment comm = new BlogPostComment();

comm.Body = "this is my first comment.";

comm.Title = "TestComment";

comm.DateCreated = DateTime.Now;

comm.Id = 0;

post.Comments.Add(comm);

---------------------------------------------------------------------------

but a exception occured while adding comments. and exception message is "The requested object was could not be found at this location, invalid Ur" of type "System.Net.WebException".

Is there any other way to add comments in blogpost? if yes then please let me konw,

Thanks,

Neelesh

All Replies
  • Hi 

    I did some changes in code now getting different exception.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Net.WebException: 409 : There were errors validating the enclosed object : Invlaid Post specified, Invalid Uri

    Source Error:

    Line 78:             comm.DateCreated = DateTime.Now;
    Line 79:             comm.ParentPostId = post.Id;
    Line 80:             post.AddComment(comm);
    Line 81:             //service.AddComment(comm, post.Id);
    Line 82: 

    Source File: f:\WebSite9\Default.aspx.cs    Line: 80

    Stack Trace:

    [WebException: 409 : There were errors validating the enclosed object : Invlaid Post specified, Invalid Uri]
       CommunityServer.WebServices.Common.BaseService.PostResponse(String url, Object body) +446
       CommunityServer.WebServices.Blogs.BlogsService.AddComment(BlogPostComment comment) +196
       CommunityServer.WebServices.Blogs.BlogsService.AddComment(BlogPostComment comment, Int32 blogPostId) +43
       CommunityServer.WebServices.Blogs.BlogPost.AddComment(BlogPostComment comment) +48
       _Default.DeleteBlogPost() in f:\WebSite9\Default.aspx.cs:80
       _Default.Page_Load(Object sender, EventArgs e) in f:\WebSite9\Default.aspx.cs:23
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +31
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +68
       System.Web.UI.Control.OnLoad(EventArgs e) +88
       System.Web.UI.Control.LoadRecursive() +74
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3021
    

  • Any Idea?

  • Me also getting same exception..

    Anybady have any idea...........

     

  • BlogsService service = new BlogsService(siteUrl, username, apiKey);

    List<BlogPost> posts = service.GetBlogPosts(blog.Id);

    BlogPost post = posts[0];

    BlogPostComment comm = new BlogPostComment();

    comm.Body = "this is my first comment.";

    comm.Title = "TestComment";

    comm.DateCreated = DateTime.Now;

    comm.Id = 0;

    // changed line
    post.AddComment(comm, post.Id);

Page 1 of 1 (5 items)