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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
a68tbird
Resolver II
Resolver II

Passing Value from Function as Parameter in URL

Hello all -

  I'm trying to pass a value retrieved from a function into an API url as a required parameter.  The function returns a number (the List ID).  The API call in M is as such:

= Json.Document(Web.Contents("https://core-base.azurewebsites.net/api/mailer/messages/90/95"), [ApiKeyName="api_key"]))

 

What I need to do is make this dynamic by replacing that last value, the List ID (95) with the value retrieved in the function.  If I concatenate the name of the function I get an error:

We cannot apply operator & to types Text and Function.

If I wrap the function in Number.ToText(), then the error becomes:

We cannot convert a value of type Function to type Number.

 

I created a test parameter with a fixed value and it works fine.  So, if I could somehow change that function output into a parameter, I do believe it will work.  

Anyone have any ideas? Or perhaps a different way to approach?

 

Thank you!

1 ACCEPTED SOLUTION
ImkeF
Super User
Super User

Hi @a68tbird ,
you need to call that function and not simply reference it.
Please try something like this:
Number.ToText(YourFunctionName())

If your function requires parameter(s), you have to pass them into the red brackets:
Number.ToText(YourFunctionName(YourParameter))

But in any case: You need the brackets to call the function.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

1 REPLY 1
ImkeF
Super User
Super User

Hi @a68tbird ,
you need to call that function and not simply reference it.
Please try something like this:
Number.ToText(YourFunctionName())

If your function requires parameter(s), you have to pass them into the red brackets:
Number.ToText(YourFunctionName(YourParameter))

But in any case: You need the brackets to call the function.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

March 2024 PBI Gallery Image

Power BI Monthly Update - March 2024

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

Top Solution Authors
Top Kudoed Authors