Forum Discussion
PowerBI and Socialbakers
Hello
Here is what works for me (connection anonymous). Note that I have used parameters (&...&). When you post on Power BI service, you will need to add to Gateway the data source and do connect anonymous for it to refresh automatically. Hope this helps.
let
url = "https://api.socialbakers.com/1/facebook/metrics",
body = "{ ""date_start"": "&date_start&", ""date_end"": "&date_end&", ""profiles"": ["&facebook&"], ""metrics"": [""fans_lifetime""]}",
Parsed_JSON = Json.Document(body),
BuildQueryString = Uri.BuildQueryString(Parsed_JSON),
Source = Json.Document(Web.Contents(url,
[Headers=[#"Content-Type"="application/json; charset=utf-8",
Authorization="Basic "&key&""],
Content = Text.ToBinary(body)])),
profiles = Source[profiles],
#"Converted to Table" = Table.FromList(profiles, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"id", "data"}, {"Column1.id", "Column1.data"}),
#"Expanded Column1.data" = Table.ExpandListColumn(#"Expanded Column1", "Column1.data"),
#"Expanded Column1.data1" = Table.ExpandRecordColumn(#"Expanded Column1.data", "Column1.data", {"date", "fans_lifetime"}, {"Column1.data.date", "Column1.data.fans_lifetime"})
in
#"Expanded Column1.data1"