How to notify specific people with yammer REST api

I would like to notify a specific set of people when posting with the Yammer REST API. The desired effect should be the same as "Add people for notification" in native web application: enter image description here

After some research with the REST API documentation, I found a field direct_to_id

in the request data object.

direct_to_id - Send a private message directly to the specified user.

I'm not sure what this attribute actually does, so I tried the following:

var data = {
    "body": "test message",
    "group_id": XXXXXX, //a valid group id
    "direct_to_id": XXXXXXXXXX, //a valid user id 
};

      

but after adding the "direct_to_id" field to the message, I get an error 400 (bad request)

. I also don't know if this method works with multiple user notifications.

+3


source to share


1 answer


Ok, I figured it out by reverse engineering the yammer embed widget. When posting with people to be notified, yammer embed sets the "cc" field in the web form, according to the fiddler: enter image description here

In javascript, just do this:



var data = {
    "body": "test message",
    "group_id": XXXXXX,
    "cc": "[[user:XXXXXX]],[[user:XXXXXX]]",
};

      

This approach is not documented in the Yammer API, so I'm not sure if it will be supported in the future. Meanwhile, I really want Yammer to have good documentation. This will save developers a lot of time and hassle.

+5


source







All Articles