cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Alena Frequent Visitor
Frequent Visitor

POST method in power query instead of GET

Hi, I'm having following issue:

I need to get the data (json file) through the power query (using token).

 

My query:

= Web.Contents("https://api.direct.yandex.ru/v4/json/", [Query=[method="GetSummaryStat", StartDate="2017-01-01", EndDate="2017-02-28", oauth_token="mytoken"]], [Content=[???????]])

 

Question is:

What should I write in "Contents" to set the method to POST as the data source requires POST method only.

Thank you!

3 REPLIES 3
v-haibl-msft Super Contributor
Super Contributor

Re: POST method in power query instead of GET

@Alena

 

Please take a look at this blog to see if it helps.

 

Best Regards,

Herbert

Alena Frequent Visitor
Frequent Visitor

Re: POST method in power query instead of GET

@v-haibl-msft

 

Tnaks for the article!

I read the documentation, and the sample of json query for my source is like that:

 

{
   "method": "GetSummaryStat",
   "param": {
      /* GetSummaryStatRequest */
      "CampaignIDS": [
         (int)
         ...
      ],
      "StartDate": (date),
      "EndDate": (date)
   }
}

 

According to it my query looks like that:

 

 

let
    url = "https://api.direct.yandex.ru/v4/json/",
    content="{""method"": ""GetSummaryStat"",
""param"": {""CampaignIDS"": [[14835862]],
""StartDate"": ""2017-01-01"",
""EndDate"": ""2017-02-01""#(lf)
}}", source = Json.Document(Web.Contents(url, [Content=Text.ToBinary(content)], [Query=[oauth_token="token"]])) in source

 

 

And still I got mistake. 

 

Best wishes,

Alena

DN Member
Member

Re: POST method in power query instead of GET

Hi @Alena. Did you make it work?

Could you please share your code here?

 

how could I use POST method using username and password? (my API does not accept tokens)
I am getting error 405 METHOD NOT ALLOWED on my code below. It seems username and password are not pushed inside API.
I am new to M language and not used to the correct syntax I think...

 

let
     apiUrl = "http://xxxxx",
     options = [Headers =[#"Content-Type"="application/json",
                        #"Authorization" = "(base64-encoded username : password)"]],
     Value = Web.Contents(apiUrl,options)

in
     Value