cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Vankod Frequent Visitor
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

Accepted Solutions
Vankod Frequent Visitor
Frequent Visitor

Re: How to add body into Web.Contents()?

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
4 REPLIES 4
Moderator v-yuezhe-msft
Moderator

Re: How to add body into Web.Contents()?

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.
Vankod Frequent Visitor
Frequent Visitor

Re: How to add body into Web.Contents()?

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
Frequent Visitor

Re: How to add body into Web.Contents()?

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
emudria Member
Member

Re: How to add body into Web.Contents()?

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