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
darko861
Resolver II
Resolver II

Anonymous access via API

Hi Community,

 

This subject has previously been discussed in this forum with mixed results. Here is the previous thread:

https://community.powerbi.com/t5/Service/Anonymous-access/m-p/21014#M5916

 

I'm facing a similar issue, with not being able to refresh the BI reports automatically in Services.

 

Here is the syntax used in Power BI desktop which extracts data from the API, and this works with no problem when using "Anonymous" authentication in Data source settings:

 

darko861_0-1620718284453.png

 

 

let
Source = Json.Document(Web.Contents("https://aptic.hrm.kontek.se/Webapi/api/employees",

[

RelativePath = "/1561ebb2-de73-454c-9c28-acee00b37dde/timereports?from=2021-04-01&tom=2023-04-30",
Headers=[Authorization="Basic 5xxx:API_Key"]
])),

#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"Date", "IsAudited", "IsTransferredToSalary", "OvertimeMarkingBefore", "OvertimeMarkingAfter", "TimeRows"}, {"Date", "IsAudited", "IsTransferredToSalary", "OvertimeMarkingBefore", "OvertimeMarkingAfter", "TimeRows"}),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded Column1",{{"Date", type datetime}, {"IsAudited", type logical}, {"IsTransferredToSalary", type logical}, {"OvertimeMarkingBefore", type any}, {"OvertimeMarkingAfter", type any}, {"TimeRows", type any}}),
#"Expanded TimeRows" = Table.ExpandListColumn(#"Changed Type", "TimeRows"),
#"Expanded TimeRows1" = Table.ExpandRecordColumn(#"Expanded TimeRows", "TimeRows", {"TimeCode", "UnsocialWorkingHoursTimeCode", "FromTime", "TomTime", "TimeInMinutes", "Accounts", "InternalComment", "ExternalComment", "Billed", "BillabledTime", "Billing", "OriginFrom", "OriginTom", "HasPadlock", "HasManuallyChangedAccount", "IsGenerated", "OriginalFromTime", "OriginalTomTIme", "IsComplete"}, {"TimeCode", "UnsocialWorkingHoursTimeCode", "FromTime", "TomTime", "TimeInMinutes", "Accounts", "InternalComment", "ExternalComment", "Billed", "BillabledTime", "Billing", "OriginFrom", "OriginTom", "HasPadlock", "HasManuallyChangedAccount", "IsGenerated", "OriginalFromTime", "OriginalTomTIme", "IsComplete"}),
#"Expanded TimeCode" = Table.ExpandRecordColumn(#"Expanded TimeRows1", "TimeCode", {"Id", "Name", "Code"}, {"Id", "Name", "Code"}),
#"Expanded Accounts" = Table.ExpandListColumn(#"Expanded TimeCode", "Accounts"),
#"Expanded Accounts1" = Table.ExpandRecordColumn(#"Expanded Accounts", "Accounts", {"IsFromTimeclock", "Id", "Name", "Code", "AccountDistribution"}, {"IsFromTimeclock", "Id.1", "Name.1", "Code.1", "AccountDistribution"}),
#"Removed Columns" = Table.RemoveColumns(#"Expanded Accounts1",{"IsAudited", "IsTransferredToSalary", "OvertimeMarkingBefore", "OvertimeMarkingAfter", "UnsocialWorkingHoursTimeCode", "IsFromTimeclock", "AccountDistribution", "InternalComment", "ExternalComment", "Billed", "BillabledTime", "Billing", "OriginFrom", "OriginTom", "HasPadlock", "HasManuallyChangedAccount", "IsGenerated", "OriginalFromTime", "OriginalTomTIme", "IsComplete"})
in
#"Removed Columns"

 

 

But when I try to schedule refresh in Power BI service then there appear to be some credential problems:

 

darko861_1-1620718548851.png

 

In the Data source settings in Services, it has established a successful connection to the API with Basic Credentials:

 

darko861_2-1620718809640.png

 

If you try to change authentication in Services to Anonymous to match the connection in Desktop, you get an error message:

darko861_3-1620719073513.png

 

Is there a way to establish a successful connection in Services where the BI reports can be updated through an automatic schedule refresh in Power BI without any problems?

 

I would really appreciate it if you can give me some suggestions on how I can solve this problem, maybe the syntax above, which works great in Desktop, should be written differently?

1 ACCEPTED SOLUTION
blopez11
Resident Rockstar
Resident Rockstar

In Power BI Desktop,
-- I would change the M code, moving "/Webapi/api/employees" to the RelativePath option and remove the Headers option all together
-- I would edit the permissions on the URL and changing type from Anonymous to Basic with the appropriate credentials

 

Once published, in the Power BI Service,
-- In the scheduled refresh settings, I would not use a gateway (looks like you are using one), and in the data source credentials, set type to basic with the appropriate credentials

 

Good luck,

View solution in original post

2 REPLIES 2
blopez11
Resident Rockstar
Resident Rockstar

In Power BI Desktop,
-- I would change the M code, moving "/Webapi/api/employees" to the RelativePath option and remove the Headers option all together
-- I would edit the permissions on the URL and changing type from Anonymous to Basic with the appropriate credentials

 

Once published, in the Power BI Service,
-- In the scheduled refresh settings, I would not use a gateway (looks like you are using one), and in the data source credentials, set type to basic with the appropriate credentials

 

Good luck,

Thank you very much! I followed your steps and it worked, I really appreciate it, this is such a great community!

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.

Top Solution Authors
Top Kudoed Authors