Yammer Network Data API - HTTP 401 Error - Unauthorised

Sam 20 Reputation points
2023-11-15T11:44:55.75+00:00

Hello There

My question is a follow up to my original post which can be found here (https://answers.microsoft.com/en-us/msoffice/forum/all/get-yammer-network-data-using-api/57e14cb8-d626-49e2-a242-0b78fbfaceda?messageId=1ddd9c73-b1d7-43cf-8f93-4e3a5687e27b) and submitted last week. I was advised to seek assistance here and I hope it's the right place for it. That post contains detailed screenshots as well which can be referred to if need be.

  • Summary:

Platform is Viva Engage

Task is to automatically download the Yammer Network Data using the API for internal use / processing.

And it's part of a project.

User Account used is admin, implicitly a Global Admin as well.
APP Registration carried out with required permissions as stated in the documentation.

API (Codeless using endpoints only)

I can get a token (API Option). I checked the whole token strings and realised yesterday it was actually being refreshed every time I ran my automation. I kept on looking at the beginning of the token string and because it's always the same (first 6 characters or there about), I assumed it was not refreshed.

The second step is obviously to Get the data and that's where I'm struggling. I keep on getting the same error. I've exhausted all avenues (Online research / testing / tweaking), "usual stuff", but to no avail.

Power Automate

I also tried using Power Automate and quickly discovered that I'm limited to 20 message max.
There was an article about possibly bypassing such limitation but that did not work. MS has updated some of the connectors to V3 as well. The output also has less info, i.e. sender names / details are missing. I'm a ble to get a JSON file but not what I'm looking for.

My API Configurations

  • Post Request to get a token (refresh)

User's image

  • JSON Response

{"token_type":"Bearer","expires_in":3599,"ext_expires_in":3599,"access_token":"eyJ0eXAiOiJKV1QiL......

Happy to provide more details of course and thank you in advance for your help.

Sameer

Viva Connections
Viva Connections
A Microsoft Viva module that provides a gateway to a modern engagement experience.
90 questions
{count} votes

Accepted answer
  1. Haoyan Xue_MSFT 21,816 Reputation points Microsoft Vendor
    2023-12-01T01:10:55.9666667+00:00

    Hi @Sam ,

    Regardless, the ending was perfect and your problem was solved. So happy for you. Thank you so much for your contribution and time. What a really great notes and steps!

    By the way, since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others."

    You could click the "Accept Answer" button for this summary to close this thread, and this can make it easier for other community member's to see the useful information when reading this thread. Thanks for your understanding!

    Thank you again.

    Regards,

    Haoyan Xue


    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Sam 20 Reputation points
    2023-11-23T16:33:59.6833333+00:00

    Resolved my own issue!


  2. Sam 20 Reputation points
    2023-11-30T11:20:46.4533333+00:00

    Hi @Haoyan Xue_MSFT

    The reason I did not provide an answer was because I assumed it was a dead post since no one got back to me.
    In the end, I had to enlist the assistance of a Microsoft support to get me on the right path. I was quite close but overcomplicated the whole process.


    The steps outlined below can also be found here: https://learn.microsoft.com/en-us/rest/api/yammer/getting-started (Much more comprehensive than my non-professional write-up)


    Pre-Requisite: Viva Engage has been setup and working. In my case, admin (onmicrosoft.com) account was used to setup the platform and is implicitly a Global Admin.

    1. Navigate to https://www.yammer.com/client_applications (I need a token to use the API hence we need to register an App in Yammer)
      Log in to this site using the account you've used to setup Viva Engage or one with Global Admin rights. At time of writing MS has introduced "MS Entra ID" (Re-branded version of Azure AD). As a result, navigate here (https://learn.microsoft.com/en-us/viva/engage/eac-key-admin-roles-permissions) to ensure you're logging in as the right user with the correct permissions.
    2. Click on "Click Here to register an App"
      User's image
    3. Fill out the form (In my case - I just use our own organisation details).
      For Application Name, I entered the Viva Group Name we are using.
      Take notes / screenshots along the way to document your own steps! Then click on Continue.
      User's image

    If all goes well, you will see the screen below. Click on "Generate a developer token for this application"
    PS: You must save that token because that's the only time you get to see it!!!
    User's image


    The App Registration part is now complete. Let's move on to the fun part. Testing the API.

    1. In my case, I'll be using the Network Data API (https://learn.microsoft.com/en-us/rest/api/yammer/network-data-export), using these examples (https://learn.microsoft.com/en-us/rest/api/yammer/network-data-export#how-this-api-works)
    2. Copy / Paste this URL (https://www.yammer.com/api/v1/export?since=2020-02-09T00:00:00+00:00) in a browser. Change the date / time if need be. The download will now begin.

    If you've managed to get the zip file downloaded then you're almost there. Next bit I needed was to automate this process and not copy/paste. The time I've spent reading / testing came in handy. That's also where MS Support ended.


    Automate the Network Data download MS did provide me with a PowerShell script to achieve this, however the script was buggy despite my best effort to fix this and no support will be provided by MS for it either. So I resumed using my automating tool (FME) to put it all into action. I created the following "Variables" (Attribute Names / Values) User's image

    You need 2 things to carry out your GET request

    • The URL as shown above
    • A Header: Header name is Authorization & Header value is (without the double quotes) "Bearer insert_your_token_value_here"

    That's it! My Automation - Deletes previously downloaded Zip file / Downloads the new zip file using the API using specific dates / Read one of the CSV from the archive / Some transformations in between / Finally write the data to 2 SQL tables. Oh! The API response will give you an ID which you can also use to monitor the progress of your download. Hope that helps any one out there and good luck :-) Cheers Sameer

    0 comments No comments