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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
preetisb15
Frequent Visitor

how to run REST endpoint in M

I am currently trying to achieve the below with M query - is this doable? any suggestions are welcome.. Thanks in advance

 

This is what I need to be able to do

 

1. First I need to run to call a REST endpoint to start the export

   https://xx.yy.io/report/export?filterType=jqlfilter&jqlFilterID=19216&columnsby=statusduration&calen...

 

 

2. running the above REST endpoint, the output will look something like the below 

   https://tis.obss.io/rest/export/3kjhrqoi-asd-3rrd34-3rerwr34-94c797e9f590 

 

I need to run the post command output to get to the data table

 

 

 

2 REPLIES 2
preetisb15
Frequent Visitor

Hi again 

 

A bit of progress with the Mquerying. this is how my Mquery looks like 

 

Screenshot 2020-06-19 at 09.32.30.png

 

When executing the first time, I get the expected results.

However when refreshing the query, I get a 404 error: 

Web.Contents failed to get contents pointing to the sourcelink given in 'webdata.2' - any suggestions how to deal with this?

 

Many thanks in advance

lbendlin
Super User
Super User

Assuming that your REST service answers with JSON, you would do something like

 

let
    Source = Json.Document(Web.Contents("https://api.powerbi.com/v1.0/myorg/gateways/" & GatewayId & "/datasources", [Headers=[Authorization=Authorization]])),

 

It becomes tricky when your request fails or when it succeeds with a malformed response (looking at YOU, MICROSOFT!)

 

let
       JsonData = try Json.Document(Web.Contents("https://api.powerbi.com/v1.0/myorg/gateways/" & GatewayId & "/datasources/" & ConnectionId & "/status", [Headers=[Authorization=Authorization]])),
       value = if JsonData[Error][Message]="We reached the end of the buffer." then "True" else "False"
    in
        value

 

In this example "We reached the end of the buffer"  is caused by a blank 200 return, and is actually the desired outcome.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors