4 Replies Latest reply on Sep 15, 2014 12:06 AM by ivanzhang

    Weird question alert:Deleting likes?

    Powell

      Say I have a piece of content, an uploaded doc or something...

      Many people have 'liked' this content. 
      Is there anyway to remove these likes from this content?

      API, directly in the DB, etc?

        • Re: Weird question alert:Deleting likes?

          Hi Powell Trusler,

          Not tried it myself but you should be able to do this with the v3 API if you use the Core V3 API - Run-As Feature & Signed Add-Ons

           

          You can get the likes for a piece of content with;

          GET /contents/{contentID}/likes

          which gives you the list of users. 

           

          Then iterate the list and delete each like for the user by using the Run-As configuration as an Admin user.

          DELETE /contents/{contentID}/likes

            • Re: Weird question alert:Deleting likes?
              Powell

              Thank you so much for the reply!

              I will give this a go today!

               

              -P

              • Re: Weird question alert:Deleting likes?
                Powell

                This worked well, thank you so much!

                • Re: Weird question alert:Deleting likes?
                  ivanzhang

                  Hi Jason,

                   

                  I use the same method but it returns 403 error.

                  Is it because of the low permission of the Admin user? Using the same admin account, I can get activities, contents and post likes. Only failed while executing deleting likes.

                   

                  string requestUrl = "https://jive.home.url/api/core/v3/contents/45060/likes"

                  using (WebClient client = new WebClient())

                  {

                      client.Encoding = Encoding.UTF8;

                      string credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(this.adminAccount + ":" + this.adminPassword));

                      client.Headers[HttpRequestHeader.Authorization] = "Basic " + credentials;

                      client.Headers[HttpRequestHeader.Accept] = "application/json";

                      client.Headers[HttpRequestHeader.ContentType] = "application/json";

                      if (!string.IsNullOrEmpty(this.currentUsername))

                      {

                          client.Headers.Add("X-Jive-Run-As", "username " + this.currentUsername);

                      }

                      string response;

                      response = client.UploadString(requestUrl, "DELETE", string.Empty);

                      response = response.Replace("throw 'allowIllegalResourceCall is false.';", string.Empty);

                   

                      return response;

                  }

                   

                  Aboving is my code. The admin account is supplied by my customer. I don't know if it is full access permission. Can you help me?