How to send announcement in yammer through api i tried below but its not working

Occasional Contributor

How to send announcement in yammer through api i tried below but its not working.Giving some security state:0 error.Even though i selected log in before posting.

 

url: "messages.json"
,headers: {'Authorization': 'Bearer GGFFBBB-88966333' }
, method: "POST"
, data: {
"body": "Msg",
"log_data[publisher_type]": "yam.ui.publisher.global.AnnouncementPublisher",
"log_data[publisher_source]": "group",
"log_data[number_of_recipients]": "1",
"invited_user_ids": "",
"skip_body_notifications": "true",
"group_id":"44556699",
"is_rich_text": "true",
"message_type": "announcement",
"title": "Title"
}
, success: function (msg) { alert("Post was Successful!"); }
, error: function (msg) { alert("Error"+JSON.stringify(msg)); }

1 Reply

Couple of things to check:

 

  1. The account you are posting with has the ability to post Announcements. (I know perhaps a daft question)
  2. The body of the message is formatted using HTML
  3. Can you post a message to the group?

 

The POST will look something like (for speed I've used the Flow so its added in a couple of extras):

 

[
  {
    "id"1120667167,
    "sender_id"1512434534,
    "replied_to_id"null,
    "created_at""2018/07/09 14:41:44 +0000",
    "network_id"41253,
    "message_type""announcement",
    "sender_type""user",
    "url""https://www.yammer.com/api/v1/messages/1120667167",
    "web_url""https://www.yammer.com/tenantname/messages/1120667167",
    "group_id"4191007,
    "title""Testing (ignore)",
    "body": {
      "parsed""Testing posting from Flow with some html\n",
      "plain""Testing posting from Flow with some html",
      "rich""Testing posting from Flow <p>with some html</p>"
    },
    "thread_id"1120667167,
    "client_type""Microsoft PowerApps and Flow (Europe)",
    "client_url""http://www.powerapps.com",
    "system_message"false,
    "direct_message"false,
    "chat_client_sequence"null,
    "language"null,
    "notified_user_ids": [],
    "privacy""public",
    "attachments": [],
    "liked_by": {
      "count"0,
      "names": []
    },
    "content_excerpt""Testing posting from Flow with some html",
    "group_created_id"4191007
  }
]