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
ziyabikram96
Helper V
Helper V

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 error3 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!

1 ACCEPTED SOLUTION
lbendlin
Super User
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

View solution in original post

4 REPLIES 4
lbendlin
Super User
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

@lbendlin  Thanks a lot!

lbendlin
Super User
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. 

 

@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!

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.