Using this topic as an example: You topic ID is 44239.
A GET to https://meta.discourse.org/t/44239.json returns an object where post_stream.posts[0].id = 194190.
I then liked your post by POSTing to https://meta.discourse.org/post_actions with id=194190&post_action_type_id=2&flag_topic=false. This request needs to be authenticated by an API key or cookies.