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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
ChristianGeiger
Frequent Visitor

Use a REST API with content in online Service (Gateway)

Hallo, 

 

i would like to use a REST API to get data from a server.  The issue on this api is , that it needs a body to work proper.

 

 

 

let
    url = "http:xxxxxxx/ExecuteCollectionQuery",
    body = "[
	{
	   ""collectionQuery"" : ""(context) => 
			context
			.Parts()	
			.OrderBy(part => part.Id)""   
	}]
",
   Source  = Json.Document(Web.Contents(url, [
	   Headers=
   			[#"Content-Type"="application/json",  
    		 #"Accept-Language"="de",
			 #"Accept"="*/*",
			 #"Authorization"="Basic cHJvY2FkOnByb2NhZA==",
			 #"User-Agent" ="ProwerBi"	
			],  Content=Text.ToBinary(body)
	]))
in
    Source

 

 

 

As you see in the code above i use 'Basic' authentication hardcoded. 

In the connector view i do not have any possibility to add a Body

 

ChristianGeiger_0-1628846652989.png

As i told when executing the query above i works in Desktop. But when publishing to the service i cannot set a refesh , because the dataset needs a gateway connection!

ChristianGeiger_1-1628846893687.png

If i want to add the source to the gateway, the connection wont work, because the api need a body,  there i cannot put a body.

ChristianGeiger_2-1628847166506.png

 

So how can i use a api in the service ?! Somehow i have to fool the service not to use a gateway, because everything is configuted in the dataset ??!

 

best regards 

 

Christian 

 

1 REPLY 1
ibarrau
Super User
Super User

Hi. You shouldn't use gateway. You are right. You can go to Schedule Refresh or Dataset configuration and look for Data Source Credentials. You have to specify the credentials only. Because this is a web source you can avoid gateway.

ibarrau_0-1628857183545.png

 

NOTE: If you have on premise data sources added to the power bi dataset you need to turn an option in your gateway to handle hybrid sources (on premise and cloud)

I hope that helps,


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.