I am able to post yammer message with below snippet.
$http({
method : "POST",
url : "https://www.yammer.com/api/v1/messages.json" ,
data:{
"body": res,
"group_id": 11XX
},
headers: {
'Accept': '*/*',
'Authorization': 'Bearer '+localStorage.getItem("socialToken"),
'accept-encoding': 'gzip',
'content-type': 'application/json'
}
}).then(function mySucces(response) {
$ionicPopup.alert({
title: 'Sucess',
template: 'Yammer Messaging Sucess'
});
}, function myError(response) {
console.log(response);
$ionicPopup.alert({
title: 'Messaging failed!',
template: 'Please login to Yammer!'
});
Now, I logged in and I posted "Anand". Now I want to like my own message. I do know it can be done with message ID and the same can be retrieved by GET Request. How do I refer it actually because I have not set any reference while posting the message.I added only comments. While posting I need to keep some reference so that it can be helpful while liking.
Yammer message IDs are dynamically allocated. It's not possible to provide or enforce a specific message ID.
When you post a message, it returns a JSON response containing details of the message if it was successfully created (201). It's in this format:
{
"threaded_extended": {},
"messages": [
{
"id": 725973788,
"sender_id": 155231522,
"replied_to_id": null,
...
So I'd suggest you consume the response on SUCCESS, extract the messages.id value then perform whatever actions you'd like. You may want to use a RESTClient to get a better feel of how it works before implementing it in your code.