Moving message threads to different group using the Yammer API image 84

Moving message threads to different group using the Yammer API

At AMIS we are quite happy users of Microsoft Yammer. Days with 10 or more messages are no exception and since December 2009, we have assembled quite a history of over 8000 message threads. Because we have joined the Conclusion eco system and we will now share a Yammer Network at that level – built with our existing network at its core – , all our All Company messages would become ecosystem wide All Company messages. It seems like a better idea to create a new group AMIS-AllCompany that is intended for AMIS staff only, that will coexist next to (Conclusion) All Company. Ideally, all our existing messages are moved from group AllCompany to this new group AMIS-AllCompany.

I have been experimenting with the Yammer REST APIs over the last few days. They are documented here: https://developer.yammer.com/docs . However, there is no API for moving messages. Several community conversations were conducted around that topic: where is the REST API for moving messages? See for example: https://techcommunity.microsoft.com/t5/Yammer/Move-a-conversation-to-another-group/td-p/2439

There is no officially documented API for moving messages. However, the Yammer web client supports the operation.

image

By inspecting the the network calls made from the web client, I could easily work out that there is a Yammer API call for moving messages.

image

The id at the end of the URL is the thread id, the group_id parameter is the id of the destination group.

The corresponding Postman request looks like this:

image

and the code in for example Node.JS:

var request = require("request");

var options = { method: 'PUT',
  url: 'https://www.yammer.com/api/v1/threads/233823545/move_to_group',
  headers:
   { 
     Authorization: 'Bearer XXXX',
     'Content-Type': 'application/x-www-form-urlencoded' },
  form:
   { isMoveThreadToGroup: 'true',
     group_id: '17438976',
     undefined: undefined } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

The message threads keep streaming in, in the destination folder. And are leaving the All Company folder at the same time.