Reply
preetisb15
Frequent Visitor
Partially syndicated - Outbound

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

Syndicated - Outbound

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

Syndicated - Outbound

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.

avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)