Forum Discussion
Web Api dataset Scheduled Refresh
Hi,
I am working on Web Api dataset Scheduled Refresh with Chris Webb's blogs as guidance. In one of his blogs, he has suggested to use Relative Path and Query options to achieve the desired goal. I am using following code to import the data in JSON Format.
=let
Contents = "{ ""recordsAfterDateTime"": ""2020-11-30T00:00:00"",
""recordsBeforeDateTime"": ""2020-12-24T23:59:59.999"" }",
Source = Json.Document(Web.Contents("https://api.trulinks.co.uk",[RelativePath = "analysis-reports/v1/api/driver-d14",Query = [q="date"]],
[Headers=[#"TT-Api-Key"="abcd", #"Ocp-Apim-Subscription-Key"="abcd",#"Content-Type" = "text/json"],Content = Text.ToBinary(Contents)]))
in
Source
But, i am getting this error: 3 arguments were passed to a function which expects between 1 and 2.
I am a noob in M language so help needed to sort out this issue. Thanks!
let
Contents = "{ ""recordsAfterDateTime"": ""2020-11-30T00:00:00"",""recordsBeforeDateTime"": ""2020-12-24T23:59:59.999"" }",
Source = Json.Document(Web.Contents("https://api.trulinks.co.uk",[
RelativePath = "analysis-reports/v1/api/driver-d14",
Query = [q="date"],
Headers=["TT-Api-Key"="abcd", "Ocp-Apim-Subscription-Key"="abcd","Content-Type" = "text/json"],
Content = Text.ToBinary(Contents)]
))
in
Source
4 Replies
- lbendlin
Super User
Web.Contents(url as text, optional options as nullable record) as binary
You provided multiple records. All your options need to be enumerated in the same record.
- ziyabikram96
Helper V
lbendlin It is returning an error : "Token RightBracket Expected". Can you please show me how to code it according to my query in the question? I would highly appreciate that. Thanks!
- lbendlin
Super User
let
Contents = "{ ""recordsAfterDateTime"": ""2020-11-30T00:00:00"",""recordsBeforeDateTime"": ""2020-12-24T23:59:59.999"" }",
Source = Json.Document(Web.Contents("https://api.trulinks.co.uk",[
RelativePath = "analysis-reports/v1/api/driver-d14",
Query = [q="date"],
Headers=["TT-Api-Key"="abcd", "Ocp-Apim-Subscription-Key"="abcd","Content-Type" = "text/json"],
Content = Text.ToBinary(Contents)]
))
in
Source- ziyabikram96
Helper V
lbendlin Thanks a lot!