6 Replies Latest reply on Sep 18, 2013 10:13 AM by nbywater

    Liking Discussions using v3 REST API

    doublemarked

      Hello,

       

      I am trying to use the v3 REST API to like a Discussion. I am POSTing to /api/core/v3/contents/<content id>/likes. I find my <content id> by fetching all discussion threads from a particular group.


      The API call succeeds, but when I do a followup GET it returns 0 Likes. I know the API call is succeeding, because the Discussion's resources.like.allowed array changes from ["GET","POST"] to ["GET","DELETE"]. Performing the same set of calls on a Blog Post behaves as expected - the POST increments the Like counter consistent with the GET response.

       

      After toying with this for a while - I discovered that in the browser, the Like is being applied to the root Message, not to the Discussion. Discussion Likes appear to be aggregating likes of all Messages beneath them. That's fine, I guess - I am able to reproduce this behavior via the API by also applying my Like to the root message (POSTing to /api/core/v3/messages/<message ID>/likes) . Unfortunately, though - the root message is NOT listed in the call to /api/core/v3/messages/contents/<content id>. I see that root message ID in my browser, but I'm not sure how I'm supposed to find it via the API.


      So at this point I'm sure what I'm supposed to do. Please advise how I can like a Discussion via the REST API?

        • Re: Liking Discussions using v3 REST API

          In the v3 API, can you use the discussion link to get the parent object? When you say that discussion likes are aggregated, what exactly do you mean? if the like counter is not incrementing, thesis sounds like a bug.

          I am cc'ing Craig McClanahan as well so he can chime in.

            • Re: Liking Discussions using v3 REST API
              doublemarked

              Hi Mark - thanks for replying.

               

              To answer your questions,

               

              1) The Discussion's parent is a Place (a Group). I am able to use the parent link to get that object, but I'm not sure that helps me to get the Discussion Likes.

               

              2) When I say the discussion likes are aggregated - I mean that when I look at my content overview page, my Discussion has a small indicator showing how many Likes there are. This indicator appears to be an aggregation of the Likes of all Messages in the Discussion. However, I just checked things again, and I don't see this aggregation via the API call, which still returns only the count on the root Message.

               

              I look forward to hearing what Craig McClanahan thinks!

            • Re: Liking Discussions using v3 REST API

              It looks like the Jive UI is not totally consistent with how it presents likes on discussions and messages:

              • On the browse contents page ({jiveURL}/content) the likes of the root message and its replies are aggregated.
              • When you display the individual discussion on its own page ({jiveURL}/thread/1234) the likes are not aggregated.

               

              The Core API follows the second style -- if you want to aggregate yourself, you'll need to read the messages that reply to the discussion and add them up.

                • Re: Liking Discussions using v3 REST API
                  doublemarked

                  Hi Craig.

                   

                  Thank you for the reply I have moved off this issue, but as I recall, I used the V2 API instead of the V3 API in order to accomplish what I needed. The V2 API seemed much more consistent with the UI. It's a bit fuzzy, though.

                   

                  I have question for you, connected with your suggestion of self-aggregation: as far as I remember there was no way to actually get the root message using the V3 API, even though in the UI (and V2 API) you are applying Likes to the root message. This would make self-aggregation impossible, would it not?

                   

                  (Forgive me if I've misspoken about something here - it's been a while since I was digging in that code!)

                    • Re: Liking Discussions using v3 REST API

                      Sorry, was on vacation last week so didn't see this until today.

                       

                      In V3, we have deliberately hidden the concept of "root message" -- in effect, the "discussion" object is also the root message.  Therefore, you can still aggregate total likes by getting the like count on the discussion, and then following the "messages" resource to get all the replies and add up their counts as well.