Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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!
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
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
User | Count |
---|---|
98 | |
91 | |
82 | |
73 | |
67 |
User | Count |
---|---|
115 | |
102 | |
98 | |
71 | |
66 |