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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
shuhn1229
Resolver I
Resolver I

Passing a Parameter to Authorization header

Hi I have a query that retrieves data from an API in POST that looks like the below:

let
    Source = let
    Source = let
    Source = let
    Source = let
 url = "https://url.com",
    body = "{""id"": ""0001"", ""variables"":  {""variable"":  ""001""}               }",
    Source = Json.Document(Web.Contents(url,[
        Headers = [#"Authorization"="Basic XX", #"Content-Type"="application/json"],
        Content = Text.ToBinary(body)
    ]))
in
    Source

 

I am trying to replace the "Basic XX" text in variable field using a parameter, lets call it "Var1". I've tried: 

#"Authorization"="{"&Var1&"}" but it does not work. How can I do this? The idea is to use a parameter to store a PW and pass it to a bunch of queries

Thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @shuhn1229 ,

Please try concatenate the type of authorization (e.g., "Basic") with the parameter that contains your password or token.

let
    Var1 = "YourPasswordOrTokenHere", // Replace with your actual password or token
    AuthorizationHeader = "Basic " & Var1,
    url = "https://url.com",
    body = "{""id"": ""0001"", ""variables"":  {""variable"":  ""001""}}",
    Source = Json.Document(Web.Contents(url, [
        Headers = [#"Authorization"=AuthorizationHeader, #"Content-Type"="application/json"],
        Content = Text.ToBinary(body)
    ]))
in
    Source

Please note that if you're using Bearer token authentication, the header should be prefixed with "Bearer" instead of "Basic".

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

View solution in original post

2 REPLIES 2
shuhn1229
Resolver I
Resolver I

I feel so dumb. Just needed to replace

#"Authorization"="Basic XX"

with

#"Authorization"=Var1

 

Anonymous
Not applicable

Hi @shuhn1229 ,

Please try concatenate the type of authorization (e.g., "Basic") with the parameter that contains your password or token.

let
    Var1 = "YourPasswordOrTokenHere", // Replace with your actual password or token
    AuthorizationHeader = "Basic " & Var1,
    url = "https://url.com",
    body = "{""id"": ""0001"", ""variables"":  {""variable"":  ""001""}}",
    Source = Json.Document(Web.Contents(url, [
        Headers = [#"Authorization"=AuthorizationHeader, #"Content-Type"="application/json"],
        Content = Text.ToBinary(body)
    ]))
in
    Source

Please note that if you're using Bearer token authentication, the header should be prefixed with "Bearer" instead of "Basic".

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.