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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Power BI REST API POST/GET calls with token Error

While trying to connect Power BI to a REST API data source with token access, I recieve this error:

DataSource.Error: The underlying connection was closed: An unexpected error occurred on a send.

 

See my code below (scrubbed of sensitive data) :

 

 

 

let
    url = "WebsiteUrl.com",
    token = "Private_token_goes_here",
    header = [#"Authorization" = "Bearer "&token&""],
    Source = Json.Document(
                            Web.Contents(
                                        url,
                                        [
                                            Headers = header
                                        ] 
                                         )
                            )

in
    Source

 

 

 

 

I have attempted the fix the error with the following solution in this post, however, I receive the below errror.

Solved: Re: Getting The underlying connection was closed - Microsoft Power BI Community

 

Expression.Error: The name 'SecurityProtocolType.Tls12' wasn't recognized. Make sure it's spelled correctly.

 

Does anyone have any suggestions regarding how I can resolve this?

 

Thanks!

2 REPLIES 2
v-eqin-msft
Community Support
Community Support

Hi  @Anonymous ,

 

According to the error message, it seemed that you have add such code in Power Query,right?

You should use Registry Editor (Desktop app) instead.

 

Or you may try method  in Powershell :

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12  

 

Refer to:

Error: System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send!

The underlying connection was closed: An unexpected error occurred on a send.

 

 

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

 

 

Anonymous
Not applicable

Eyelyn,

 

I have confirmed that these values in my registry are already set in accordance with the references above and additionally I have run the Powershell command. Unfortunately, I am still recieving the same error.

 

Not sure if it helps, howerver, In my trace file I see an error entry stating that: "Authentication failed because the remote party has closed the transport stream."

 

Why am I still seeing this error/what is the power query syntax to force Tls1.2?

 

Regards,

Jeremy

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.