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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
rush
Helper V
Helper V

POST API Call in Power Query

Hi Power BI Community

 

I am struggling with calling an API in Power Query. I am not good at the framework of how I would call an API that requires a static bearer token along with a body and headers. I called it successfully in POSTMAN but need help with the code in Power Query.

 

Please see my code below which I have changed the token and other elements for data security:

 

Thanking you very much in advance.

 

 

let
    url = "https://sb2.replicon.com/ATP/services/ReportService1.svc/GenerateReport",
    body = "reportUri"= "urn:replicon-tenant:af0682a50:report:4ca3-93bf-5b0f5dc07dc7",
    filterValues = [],
    outputFormatUri = "urn:replicon:report-output-format-option:csv",
    Source = Json.Document(Web.Contents(url,[Content=Text.ToBinary(body),
    Headers=
    [#"Content-Type"="application/json"]
    [#"X-Replicon-Application"]="companykey-leaveatp"]
    [#"Authorization"] = "Bearer IzJ6ZGW1ZDA2ZDMDk"
    ]))
    
in
    Source

 

 

2 REPLIES 2
v-luwang-msft
Community Support
Community Support

@v-luwang-msft Thanks but I am not winning with that info.

 

I adjusted the query which is giving me an invalid identifier error:

 

 

	let
    url = "https://sb2.replicon.com/ATP/services/ReportService1.svc/GenerateReport",
    body  = "reportUri"= "urn:replicon-tenant:503a24bcd3809:report:d6b-b33c-4ca3-93bf-5dc7",
    filterValues = [],
    outputFormatUri = "urn:replicon:report-output-format-option:csv",
    Source = Json.Document(Web.Contents(url,[Content=Text.ToBinary(body),
    Parsed_JSON = Json.Document(body),
    BuildQueryString = Uri.BuildQueryString(Parsed_JSON),
    Source = Json.Document(Web.Contents(url,
    [Headers = 
    [#"Content-Type"="application/json"],
    [#"X-Replicon-Application"="companykey-leavebalance"],
    [#"Authorization" = "Bearer llOThhZGE1ZDDA2ZDM4MDk"],	
	Content = Text.ToBinary(BuildQueryString)]  ))
in
    Source

 

 

rush_1-1670580406014.png

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.