Forum Discussion

a68tbird's avatar
a68tbird
Resolver II
2 years ago
Solved

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!

  • 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.

     

1 Reply

  • ImkeF's avatar
    ImkeF
    Community Champion

    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.