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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.