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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Anonymous
Not applicable

Missing Authorization in connection string

Hi! I have a report that retrieves data via an API. The code looks like this:

 

 

Source = Json.Document(Web.Contents("https://XXXX/api/external/statistics/v1?from_date=2020-09-01&to_date=2020-10-01&environment=live&language=sv-SE&key=conversation_count", [Headers=[Authorization="XXXXXX"]])),

 

 

This works fine, but when I upload the file to the Power BI report server, authorization is not included in the connection string. I get this error message: The report server couldn't connect to the data source using the information you entered. Make sure you've entered the connection string and any credentials correctly. 

 

How should I do so that authorization is included in the connection string? I can not edit it in report server. I need to have autorization as a header, otherwise it wont work. 

 

Best regards, Sophia

3 REPLIES 3
PhilipTreacy
Super User
Super User

Hi @Anonymous 

What type of Auth is it? 

How does the Auth need to be provided? In encoded form like this?  

 

EncodedCredentials = "Basic " & Binary.ToText(Text.ToBinary(ClientID & ":" & Secret), BinaryEncoding.Base64),
    
    Token_Response  = Json.Document(Web.Contents(api_url,
    [ 
      Headers = [#"Content-Type"="application/x-www-form-urlencoded",#"Authorization"=EncodedCredentials],
      Content=Text.ToBinary("grant_type=client_credentials")
    ]
    )
    )

 

 

Or plain text?

 

data= Json.Document(Web.Contents(api_url,
   [ 
     Headers = [#"Authorization"="Bearer "&token,#"Content-Type"="application/json"]
   ]
   )
   )

 

 

Regards

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

Hi again! @PhilipTreacy 

 

I tried to create a new report that I retrieve data via the same api, but this time it says that there is no data source in the power bi report server.

Scheduled Data Refresh is not available for reports. The report does not have any external data connections defined or is using an unsupported data source. Learn more

 

In the report, there are data sources under "Global Permissions" but not "current file".

 

/Sophia 🙂 

Anonymous
Not applicable

Hi again, thank you! @PhilipTreacy 

 

Sorry but I do not know much about APIs, I just followed a guide. I have got one Bearer token. I have entered it like plain text and it works fine until i upload it on Report Server. When Power BI ask me to enter credentials, i choosed anonymous. How can it work locally on my computer but not on report server?

 

Regards Sophia

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.