cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
efilipe
Helper IV
Helper IV

PowerBI and Socialbakers

Hi guys,

 

Can't find much about PowerBI and Socialbakers here. Socialbakers was unable to help me on their support.

 

I'm trying to call their API. I tried many ways and today I started to update a code I found here:

 

	let
    data = [ date_start= "2019-01-01",
             date_end= "2019-12-01",
             profiles= {"01234567890"},
             metrics= {"fans_lifetime"}],
    header = [  #"Authorization"="Basic TWpBek9UYzFYekddddjahsdfkaskjdfhksahdfkajsfd",
                #"Content-Type"= "application/json"],
    response = Json.Document(Web.Contents("https://api.socialbakers.com/1/facebook/metrics", [Content=Json.FromValue(data)])),
    out = Json.Document(response,1252)
in
    out

 

but I get the error:

 

 

 

Any suggestions?

 

Thanks!

 

5 REPLIES 5
karthikEdiga
Regular Visitor

Even I am facing auntentiaon issue. Its not allowing to load Powerquery

smarguin
Advocate I
Advocate I

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"

 

efilipe
Helper IV
Helper IV

error:

error_1.png

Hi @efilipe ,

Based on the error message, it is caused by your authentication. Please clear out the permission and re-connect again.

5.PNGClear permissions.PNGauthentication.PNG

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

What Social Backes wants:error_2.pngerror_3.png

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!