Forum Discussion
shivendr
2 years agoHelper I
Help in configuring API call in Power Query for refresh in Power BI services
Hi , I am connected with Hubspot using Private app and Oauth2.0. for connection I have written Mcode in a blank query like : let apiUrl = "https://api.hubapi.com/crm/v3/properties/deals", apiK...
Anonymous
2 years agoNot applicable
Hi shivendr ,
Please see the solution posted under this thread:
Solved: Re: Not Able to Refresh the Dataset :You Can’t sch...
Web.Contents(), M Functions And Dataset Refresh Errors In Power BI
Please try like:
let
apiUrl = "https://api.hubapi.com/crm/v3/properties/deals",
apiKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
headers = [
#"Authorization" = "Bearer " & apiKey,
#"Content-Type" = "application/json"
],
options = [
Headers = headers
],
allData = List.Generate(
() => [url = apiUrl, options = options, page = 1],
each [page] <> null,
each [
url = apiUrl & "?limit=100&page=" & Text.From([page]),
options = options,
page = [page] + 1
],
each
let
response = Web.Contents("https://api.hubapi.com", [RelativePath="/crm/v3/properties/deals?limit=100&page=" & Text.From([page]), Headers=headers]),
json = Json.Document(response),
results = json[results]
in
if List.IsEmpty(results) then null else results
),
records = List.Combine(allData),
table = Table.FromRecords(records)
in
table
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum