Adding Likes to blog/page

MichaelMoe June 16, 2015

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

2 votes
Stephen Deutsch
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 17, 2015

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.

MichaelMoe June 18, 2015

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.

Stephen Deutsch
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 18, 2015

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

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 18, 2015

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

MichaelMoe June 18, 2015

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
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 16, 2015

I don't think the REST interface handles like yet.  The basics are at https://docs.atlassian.com/atlassian-confluence/REST/latest/ 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?)

MichaelMoe June 16, 2015

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

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 16, 2015

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

MichaelMoe June 16, 2015

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

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 16, 2015

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.

MichaelMoe June 16, 2015

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.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 16, 2015

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

MichaelMoe June 16, 2015

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
TAGS
AUG Leaders

Atlassian Community Events