The one I need – to create a Yammer Group – is this one :
The best approach is to simply call the REST API – using the .NET Web Client classes (HttpWebRequest).
It follows that you need to do a POST to this URL – the clincher is to define an ‘accessToken’ to do so. This is like a SharePoint 2013 style ClientId/ClientSecret.
Click here to register your app, and get the token – it is then registered against YOUR Yammer network.
You’ll get a CLIENTID and CLIENTSECRET – need to plug these into the following URL >
And then you’ll get a CODE value. THEN, need to call the following >
And you’ll get a TOKEN – which is the magic bean you need for the following C# code.
Here’s some doco about it >
Then – you can just call the following method within C# :
private static string PostYammerJson(string url, string accessToken)
//make the request
string json = null;
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.Method = “POST”;
request.Headers.Add(“Authorization”, “Bearer” + ” ” + accessToken);
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
Encoding encode = Encoding.GetEncoding(“utf-8”);
StreamReader reader = new StreamReader(response.GetResponseStream(), encode);
json = reader.ReadToEnd();
Within the C# code – I can then do this :
string postUrl = “https://www.yammer.com/api/v1/groups.json?name=CoolPeople&private=false”;
//replace with what you get from Yammer register App page
string accessToken = “1234567890qwertyuiop”;
This is a GREAT pattern – thanks to the folk at the Microsoft PnP on GitHub.
There’s a whole solution/project that does this – and a LOT more – great examples :