Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
BroomJ
Frequent Visitor

Issues with Custom Connector to Microsoft Graph API

Hello all,

 

I'm having some issues using a custom connector to get what I want out of the Microsoft Graph API. Essentially, what I am looking to do is take the "Email Activity User Detail" report and turn it into a nice Power BI report for some people to use. The URL for that report is as follows:

 

https://graph.microsoft.com/v1.0/reports/getEmailActivityUserDetail(period='D7')

 

In order to create this custom connector, I have been using the following example as I'm not very familiar with the use of Power Query, nor the Graph API:

 

https://github.com/Microsoft/DataConnectors/blob/master/samples/MyGraph/README.md

 

I have created the connector and can connect to the API and everything, but rather than return me the data, all the query does it return me a byte array I can't seem to do anything with:

 

image.png  

 

From looking at fiddler traces, the actual data I want is being picked up along the way, but it looks like the Graph API uses a redirect URL to the download, which I'm not sure my Power Query code is handling. I think it may just be returning the redirect URL rather than the actual data.

 

Further to this, my query has no code to handle the NextLink if it goes over the number of returned rows (I think 200?), so I imagine it will not return the full dataset once I do get it working. How is this best handled?

 

Any assistance would be greatly appreciated.

3 REPLIES 3
steeno
New Member

You are using the v1.0 of the Graph API.  This only supports getting the results of the report in csv format.  this explains the 302 redirect you get which points you to the binary stream of the CSV file you can download.

 

The beta version of this supports specifying the return type of application/json:

https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/reportroot_getemailactivityu...

 

here is the sample from the above page:

 

GET https://graph.microsoft.com/beta/reports/getEmailActivityUserDetail(period='D7')?$format=application/json

 

 

steeno
New Member

Hi,

 

 

You are using the graph api v1.0 which only supports downloading this data as a CSV file, which is why when you follow the 302 redirection.

 

If you use the beta version of the same reports, see first link below, MS has added the option to return the JSON vs. CSV which will work much better for PowerBI.

 

https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/reportroot_getemailactivityu...

 

https://graph.microsoft.com/beta/reports/getEmailActivityUserDetail(period='D7')?$format=application/json

v-chuncz-msft
Community Support
Community Support

@BroomJ,

 

You may check if Binary functions help.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors