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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Alena
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
Employee
Employee

@Alena

 

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

 

Best Regards,

Herbert

@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

Anonymous
Not applicable

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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