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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Jayendran
Solution Sage
Solution Sage

How to pass the value from one source to another in Power Query ?

Hi,

 

I'm trying to find a way to pass the value of bearer token from a text file to my API

 

Source = Json.Document(Web.Contents("https://api.powerbi.com/v1.0/myorg/gateways"),[Headers=[Authorization="Bearer "+ Lines.FromBinary(File.Contents("C:\works\pbi\Bearer.txt"))

But I was not able to successfully go through the step.

 

My Text file only contains the Bearer value like below

 

Capture.JPG

 

 

 

1 ACCEPTED SOLUTION

Hi @Jayendran,

I hope it'll work now 🙂

Use Text.FromBinary instead of Lines.FromBinary. Because Lines.FromBinary returns a list of strings, but you want to have just one value of the data type text.

View solution in original post

5 REPLIES 5
Nolock
Resident Rockstar
Resident Rockstar

Hi @Jayendran,

I personally recommend to split a long expression into shorter ones because you can debug every step separately.

The problem in your query was using + for concatenating of strings instead of &.

 

TokenType = "Bearer",
Token = Lines.FromBinary(File.Contents("C:\works\pbi\Bearer.txt")),
Source = Json.Document(
Web.Contents("https://api.powerbi.com/v1.0/myorg/gateways"),
[Headers=[Authorization=TokenType & " " & Token]]
)

Hi @Nolock 

 

I tried your solution, It giving error like below

 

Expression.Error: We cannot convert a value of type Record to type Number.
Details:
Value=Record
Type=Type

 

This is my new code

 

let
    TokenType = "Bearer",
    Token = Lines.FromBinary(File.Contents("C:\Jay\works\pbi\Gateway_Report\Bearer.txt")),
    Source = Json.Document(Web.Contents("https://api.powerbi.com/v1.0/myorg/gateways"),[Headers=[Authorization=TokenType & " " & Token]])

in
   Source

Hi @Jayendran,

there is also another problem I haven't seen before. There was a wrong bracket in the function Web.Contents.

 

let
    TokenType = "Bearer",
    Token = Lines.FromBinary(File.Contents("C:\Jay\works\pbi\Gateway_Report\Bearer.txt")),
    Source = Json.Document(Web.Contents("https://api.powerbi.com/v1.0/myorg/gateways",[Headers=[Authorization=TokenType & " " & Token]]))

in
   Source

Thanks @Nolock  another error now Smiley Sad

 

Expression.Error: We cannot apply operator & to types Text and List.
Details:
Operator=&
Left=Bearer
Right=List

 

Any clue to fix this ?

Hi @Jayendran,

I hope it'll work now 🙂

Use Text.FromBinary instead of Lines.FromBinary. Because Lines.FromBinary returns a list of strings, but you want to have just one value of the data type text.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors