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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
papi0506
Frequent Visitor

Power query using variables in script blocks for POST API calls

Still new to power bi and it truly is a powerful tool. I'm running into one road block with my power query. The only way I've been able to make a proper POST API call to retreive data is by putting the Content of the Web.Contents body in a type of script block. This places quotes around the entire block for values to be taken as writen, but does not allow for they use of variables or parameters inside. 

Example in the screenshot works perfect, but I need to be able to use parameters preferably that way values can be changed for the same call. 
works like a charmworks like a charmwould like to use variables or parameters for dynamic valueswould like to use variables or parameters for dynamic values

 

The last screenshot, I've tried variables of different types and even parameters, but they break the syntax. 

 

Any help is greatly appreciated. 

 

 

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @papi0506 

Try concatenating the string pieces rather than having everything in one string. Place the following M code in a blank query to see an example

let
    #"tryagain" = "GetInThere",
    BodyContent_=  "{ ""password"" : " & #"tryagain" & " }"
in
    BodyContent_

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

View solution in original post

4 REPLIES 4
AlB
Community Champion
Community Champion

Hi @papi0506 

Try concatenating the string pieces rather than having everything in one string. Place the following M code in a blank query to see an example

let
    #"tryagain" = "GetInThere",
    BodyContent_=  "{ ""password"" : " & #"tryagain" & " }"
in
    BodyContent_

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

papi0506
Frequent Visitor

Hey @AlB


Thank you so much, your suggestion worked like a charm. I had been looking for the proper syntax to all concatening strings together. This was exactly what I was looking for. 

Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

Can you paste the query as text in this post so that experts can work on your query? 

I'll keep that in mind for next time. AIB's suggestion worked perfectly and I can even use it with parameters now {yeaaaa}. Thank you very much tho.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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 Solution Authors