Forum Discussion

xorrkaz's avatar
xorrkaz
Genius
12 years ago

Creating comments using the REST API

Is it possible to post a new comment to a TKB article using the REST API?  I could not find a way to do this.  The only API I found was to post to a board or reply to a message.  I found no way to add a comment (perhaps the reply API will work if the interaction style is TKB?).

  • AdamN's avatar
    AdamN
    Khoros Oracle

    Hi xorrkaz,

     

    As far as the REST API is concerned, you should be able to treat a TKB node as any other REST API "Board" object, and TKB articles as any other REST API "Message Discussion" object. This is similarly for other interaction styles as well (blog, idea, etc)

     

    For example...

     

    Board/TKB:

    http://lithosphere.lithium.com/t5/developers-knowledge-base/tkb-p/studio%40tkb

    http://lithosphere.lithium.com/restapi/vc/boards/id/studio%40tkb

     

    Thread/Article:

    http://lithosphere.lithium.com/t5/developers-knowledge-base/Displaying-components-based-on-authentication-status-and-role/ta-p/42992

    http://lithosphere.lithium.com/restapi/vc/threads/id/42992

    • xorrkaz's avatar
      xorrkaz
      Genius

      Thanks, Adam, but I want to post a comment to an existing TKB article.  I know how to post a new message to a board or edit an existing message, but how to I post a comment to a TKB article?

      • AdamN's avatar
        AdamN
        Khoros Oracle

        Hi xorrkaz,

         

        Apologies if I wasn't clear in my response. Because a TKB Article is treated as a "MessageDiscussion" by the REST API, you can use the "reply" method for that class to post a reply/comment:

        /restapi/vc/threads/id/45/reply

         Here are the parameters currently available:

        message.author (optional) : User - the message author. If this parameter is specified, the caller must have permission to post as this user or the call will fail. The author can be specified as a relative REST API path, such as id/43 to specify the author by id or login/username to specify the author by username, or by an absolute path beginning with a forward slash, like /users/id/43.
        message.subject (optional) : string - the message subject
        message.teaser (optional) : string - the message teaser
        message.body (optional) : string - the message body
        tag.add (optional) : string - the tags to be added to the message
        label.labels (optional) : string - The labels for the message
        message.is_draft (optional) : boolean - true if the message is a draft
        message.added_contributor_logins (optional) : string - the contributors to be added to the message
        message.post_date (optional) : date_time - the contributors to be added to the message
        qanda.is_answer (optional) : boolean - whether or not this is a qanda answer

         

        Not all of these will necessarily apply to TKB article comment (ie. qanda.is_answer), but you'll probably at least want to include message.author (if you're not authenticated as the comment author), message.subject, and message.body. For example, if you're already authenticated as who you want to post with, you can do something like:

        /restapi/vc/threads/id/3007/reply?message.subject=my%20comment&message.body=this%20is%20my%20comment