Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.