Hi Gursimrat ,
When you hit the API request in the browser URL bar, you are using the GET method.
It seems that the API "kudos give" does not support the GET method. Here is the documentation of the function.
So you need to use the AJAX function to give a kudo with the POST method.
I usually use the POST method when I need to update the database (give a kudo, post a comment, etc.) and the GET method to load a message, or any data.
Try this javascript code in your browser's console:
function giveAKudo (messageId) {
// The API url, with '?xslt=json.xsl' parameter to get the result in JSON
var url = '/restapi/vc/messages/id/' + messageId + '/kudos/give?xslt=json.xsl';
// The XMLHttpRequest object for AJAX
var xhr;
if (window.XMLHttpRequest) { xhr = new XMLHttpRequest(); } else { xhr = new ActiveXObject("Microsoft.xhr"); }
// What you want to do when the API call succeeded (or not)
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
// Parse the response to check if everything is fine. Note that I use jQuery ($) for older browsers.
var responseJSON = JSON && JSON.parse(xhr.responseText) || $.parseJSON(xhr.responseText);
if (responseJSON.response.status == 'success') {
alert('You successfully gave a kudo !');
} else {
alert('It didn\'t work :(');
}
}
};
xhr.open("POST",url,true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send();
};
Then, for a message whose Id is 3241, just call giveAKudo(3241). Check eventually on the Lithium message page if the kudo was given.
Regarding the user rights and Lithium API, you have to allow users to use them (it is in french but it should be the same lines for you).
Here is a screenshot of what I mean:
I hope it will help!
Henrik