Create Office 365 Yammer connected groups programmatically

To be able to create O365 Yammer connected groups, you will have to do some configuring first.

First, you will need to register a Yammer application to obtain a Yammer access token. When creating a Yammer connected group, you will use the Yammer API, therefore you will need an access token to make REST calls. Second, you will need to enforce O365 identity in Yammer (more on that below).

Register a Yammer application and obtain a Yammer access token

Navigate to the following URL: https://www.yammer.com/client_applications.

Login with an admin O365 account and register a new application by clicking the “Register new App” button.

The website and redirect URI are required fields, but you can put any URI in there, it will not make any difference in the token generation.

Once you register your application, click on the ‘’Generate a developer token for this application” to generate a Yammer access token. Copy the token, since you will need it later.

Enforce O365 identity and activate the connected groups option in Yammer

Enforcing O365 identity means that all of your users will only be able to login into Yammer using their O365 accounts. In addition, it will override any custom authentication setups that you have for Yammer.

Go to https://www.yammer.com.

Login with a Global Administrator account. Choose the settings icon from the top left corner.

Yammer Settings

Then choose “Network Admin”. Under the “Content and Security” section, choose “Security Settings”. Enable the “Enforce Office 365 Identity” check box and then click okay on the next screen.

As you already might know, there are two types of Yammer groups, public and private. For the private groups you can additionally choose between a visible private group that appears in the search results and is visible in your network directory or a hidden private group, which is hidden from the search results and visible only to approved users.

In the case of O365 Yammer connected groups, you will have to choose between a public group or a visible private group. This means that if you create a hidden private group, the associated O365 resources will not be generated.

Create a Yammer connected group using Yammer REST API

To create an O365 Yammer connected group programmatically, you will have to make a POST request on the Yammer API with the previously obtained access token.

The endpoint of the Yammer API is https://www.yammer.com/api/v1/groups.json.

You can use two parameters when making the request:

  • name – the name of the group
  • private – whether the group will be private or not


$yammerAccessToken = Read-Host -Prompt "Enter a Yammer access token: "
$yammerNewGroupName = Read-Host -Prompt "Enter a name for the group: "

$yammerGroupAPI = ("{0}?name={1}&private={2}" -f "https://www.yammer.com/api/v1/groups.json", $yammerNewGroupName, $true)

$reqHeaders = @{
"Accept" = "*/*"
"Authorization" = "Bearer "+ $yammerAccessToken
"accept-encoding" = "gzip"
"content-type" = "application/json"

$yammerNewGroup = Invoke-WebRequest -Method POST -Uri $yammerGroupAPI -Header $reqHeaders


bool isPrivate = true;

string yammerGroupUrl = string.Format("{0}?name={1}&private={2}", 
"https://www.yammer.com/api/v1/groups.json", "group name", isPrivate);

PostRequest(yammerGroupUrl, accessToken);

public string PostRequest(string requestUrl, string token)
       string jsonResponse = string.Empty;

       HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUrl);
       request.ContentType = "application/json; charset=utf-8";
       request.Accept = "*/*";
       request.Headers.Add("Authorization", "Bearer " + token);
       request.AutomaticDecompression = DecompressionMethods.GZip;
       request.Method = "POST";
       request.ContentLength = 0;

       HttpWebResponse response = request.GetResponse() as HttpWebResponse;
       using (Stream stream = response.GetResponseStream())
          using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
             jsonResponse = reader.ReadToEnd();

       return jsonResponse;

As a result (if the POST call to the Yammer API was successful), you will get an O365 Yammer connected group with the following O365 resources.


These resources can be accessed from the Yammer group page in Yammer.

Biserka Cvetkovska

Leave a Reply

Your email address will not be published. Required fields are marked *