Adding Likes to blog/page

I've been issuing SQL statements against Confluence Database to add likes to blog/page. But I just saw "Confluence Like REST API" on Confluence Administration page, Add-on section.  Does it mean that there's a REST API to add likes? I searched online but there's no result relating to that. Anyone know, if that's possible?

2 answers

It's a private method, but it's certainly possible.  You can see it if you monitor your traffic (when clicking the like button) and/or use the REST API Browser. It is:

(contextPath) /rest/likes/1.0/content/{id}/likes

and you can do either a GET (to see likes), POST (to like), and DELETE (to unlike).  The limitation is that the like is applied to the currently logged-in user, so you can't like a page for someone else. To do that, you would have to use a server method or modify the database.

It maybe a better option even though I still need to update the database. Because, right now, I need to generate id for every like I insert(I just increment the largest id by one) and it kind of scares me. With REST approach, I don't need to generate id. I just need to update the username and creationdate. That said, you mentioned server method and I'm not familiar with that. How do I access those methods? Our Confluence is hosted on Cloud by the way.

If your confluence is hosted on Cloud, how are you modifying the database?

Heh. Yes, REST is the only option for Cloud.

Ok My bad. It's not on cloud. It's hosted on VM running on AWS. So, I have access to the database.

1 vote

I don't think the REST interface handles like yet.  The basics are at and doesn't mention it.

(I am mildly intrigued by your SQL though - how do you handle the cache clearing and reindexing after running the SQL?)

For the time being, I use user-interface ("Confluence Admin" > "Cache Statistics"). Later, I may use REST API.

Erk, that's no good, how do you do the indexing?

Same way - Context Indexing/Rebuild. Could you tell my why it isn't good?

So you're running a huge indexing operation every time you use SQL? Are you taking Confluence offline when you do this SQL as you need to? Sounds like you're having to make it usable all the time.

I'm just working on test site. So, I don't need to take it offline. What I do is, I have nodejs script that imports contents and likes, and updates creation date and whatnot. I have to manually flush the cache and rebuild the index after.

Ah. Yes you do. Never write to a Confluence database while it is running.

Didn't think of that. You are right, I should keep it offline. Any other suggestion to keep database from corrupting?

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Feb 06, 2019 in Confluence

Try out the new editing experience

Hi team, I’m Avinoam, a product manager on Confluence Cloud, and today I’m really excited to let the Community know that all customers can now try out the new editing experience and see some of the ...

1,104 views 58 8
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you