2 Replies Latest reply: Aug 2, 2013 12:35 PM by JRSim_UIX RSS

    How to use WebCenter REST API to like or comment a activity

    user10351697
      Hi all

      I want to know how to realize like or comment function with REST APIs.

      I execute a REST call with following url, but the 'like' counter is not be increased.
      http://cdcjp77vm3.cn.oracle.com:8888/rest/api/activities/services/oracle.webcenter.community/objectTypes/groupSpace/objects/(s2518c69b_1989_4a63_8886_c32075c76b9c)/likes?&utoken=FDNA-Z7ekZuPnVSNoPWOqTJ2IzAE_w**

      Is there anything i missed?

      Can anyone give me an example about how to use this API to like or comment a activity?

      Thanks

      Qian
        • 1. Re: How to use WebCenter REST API to like or comment a activity
          JRSim_UIX

          I'm not sure if this is a bug; I'm trying on my local VM and only seem to be able to get the resource type to show/work with documents.

          urn:oracle:webcenter:comments,,,

          This shows the capabilities you can then use to pass the correct object to the above.

          I think there was an update to the REST API the comments, likes were moved in PS4 which doesn't seem to have been moved across successfully for other activities...

          Qian your Oracle right can you just push this through to support and let me know if it is a bug with only documents being able to access resource types above..

           

           

          So for others reading this -

           

          Retrieve Comments

          /rest/api/activities/services/{serviceId}/objectTypes/{objectType}/objects/({objectId})/comments?startIndex={startIndex}&itemsPerPage={itemsPerPage}&utoken={token}

           

          Retrieve Likes

          /rest/api/activities/services/{serviceId}/objectTypes/{objectType}/objects/({objectId})/likes?startIndex={startIndex}&itemsPerPage={itemsPerPage}&utoken={token}

           

          Example

          /rest/api/activities/services/oracle.webcenter.doclib/objectTypes/document/objects/(Shomw-Portal-Content%2523dDocName%253ASMP_013033)/likes?startIndex=0&itemsPerPage=10&utoken=Blah1234

           

          If you want to retrieve all summary likes info in the initial request make sure you add data=data,commentsSummary,likesSummary to the urn:oracle:webcenter:activities:stream template

           

          This should retrieve all the info you are looking for

          ?personGuid=@me&personal=true&userGroupSpaceActivities=true&data=data,commentsSummary,likesSummary&startIndex={startIndex}&itemsPerPage={itemsPerPage}&utoken=FM--LTWjK_ieJCCne2z5sS_DoXv4_w**

           

          Qian - I'm not sure the objects/ params:values to pass for commenting and making likes.

           

          I'm guessing {data:'this is a comment'}

          unfortunately documentation seems to be missing for comments, likes..

           

          I'll need to dig into the code and see if I can find out what its expecting.

          • 2. Re: How to use WebCenter REST API to like or comment a activity
            JRSim_UIX

            So Qian;

            looking through the code this is how you can


            Post a comment (POST)

            /rest/api/activities/services/{serviceId}/objectTypes/{objectType}/objects/({objectId})/comments?startIndex={startIndex}&itemsPerPage={itemsPerPage}&utoken=blah


            {key:val}

            {text:'this is my comment)


            Edit a comment (PUT)

            So I haven't tried it but it should do the trick.. although I don't see update under capabilities so you may get blocked.

            /rest/api/activities/services/{serviceId}/objectTypes/{objectType}/objects/({objectId})/comments?startIndex={startIndex}&itemsPerPage={itemsPerPage}&utoken=blah


            {

                id: {commentId},

                text: 'changed my comment.. magic'

            }


            Delete a comment (DELETE)

            /rest/api/activities/services/{serviceId}/objectTypes/groupSpace/objects/({objectId})/comments/{commentId}?utoken=blah


            Like POST

            /rest/api/activities/services/{serviceId}/objectTypes/{objectType}/objects/({objectId})/likes?startIndex={startIndex}&itemsPerPage={itemsPerPage}&utoken=blah

            I passed it an empty object {} seemed to work for me.

             

            Unlike (DELETE)

            /rest/api/activities/services/oracle.webcenter.community/objectTypes/groupSpace/objects/({objectId})/likes/({likeId})?utoken=blah

             

            Let me know if this works for you