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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.