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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Vankod
Frequent Visitor

How to add body into Web.Contents()?

I need to add Body

{
   "method": "get",
   "params": {
      "SelectionCriteria": {},
      "FieldNames": ["Id", "Name"]
   }
}

in Web.Contents() query.

 

I can not understand how to do it.
Is this even possible in Web.Contents()?

_________________________________________

 

Current code:

let
    Source = Json.Document(Web.Contents("https://api-sandbox.direct.yandex.com/json/v5/campaigns", [Headers=[Authorization="Bearer AQAAAAANlKwBAAQQn4WfgbuD9xxxx"]]))
in
    Source
1 ACCEPTED SOLUTION
Vankod
Frequent Visitor

Done!

 

Solution from here: https://eriksvensen.wordpress.com/2014/09/15/specifying-json-query-in-power-query-example-statistics...

 

let
	content = "{
		""method"": ""get"",
		   ""params"": {
		      ""SelectionCriteria"": {},
		      ""FieldNames"": [""Id"", ""Name""]
		   }
	}",

	Source = Json.Document(Web.Contents("https://api-sandbox.direct.yandex.com/json/v5/campaigns", [Headers=[Authorization="Bearer AQAAAAANlKwBAAQQn4Wfgbxxxxxxxxxx"], Content=Text.ToBinary(content)]))
in
    Source

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Thanks for your post .

I am trying to do a similar connection to an url, however I don’t see the table with the information that I need.
This is the code I am using:

let
url = “https://urladdress”,
body = “{ “”statisticType””: “”[“”CMD_Stock””]””, “”startDate””: “”2020-04-07″” , “”endDate””: “”2020-04-07″” }”,
Source = Json.Document(Web.Contents(url,[Headers = [#”Content-Type”=”application/json”], Content = Text.ToBinary(body) ] ))
in
Source

I need to obtain the following structure in Power BI (a table with three columns):

statisticType startDate endDate
CMD_Stock 07/04/2020 07/04/2020
CMD_Stock 07/04/2020 07/04/2020
CMD_Stock 07/04/2020 07/04/2020

 

Can you help me? Thanks mdsr.

v-yuezhe-msft
Microsoft Employee
Microsoft Employee

Hi @Vankod,

What requirement do you want to achieve by adding the body?


Add another blank query in Query Editor, then paste the following code in Advanced Editor, does it return your expected result?

let
Source = Json.Document("[
{
   ""method"": ""get"",
   ""params"": {
      ""SelectionCriteria"": {},
      ""FieldNames"": [""Id"", ""Name""]
   }
}]")
in
    Source

 

1.PNG

 

Thanks,
Lydia Zhang

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks, @v-yuezhe-msft!
It's return JSON body content. This is useful step
But how to use it in Web.Contents() query?

Vankod
Frequent Visitor

Done!

 

Solution from here: https://eriksvensen.wordpress.com/2014/09/15/specifying-json-query-in-power-query-example-statistics...

 

let
	content = "{
		""method"": ""get"",
		   ""params"": {
		      ""SelectionCriteria"": {},
		      ""FieldNames"": [""Id"", ""Name""]
		   }
	}",

	Source = Json.Document(Web.Contents("https://api-sandbox.direct.yandex.com/json/v5/campaigns", [Headers=[Authorization="Bearer AQAAAAANlKwBAAQQn4Wfgbxxxxxxxxxx"], Content=Text.ToBinary(content)]))
in
    Source
Anonymous
Not applicable

@VankodLovely, had wasted lot of time in trying to fect something, your reply helped me resolve it 🙂

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Top Solution Authors