Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago

dynamic API call depending on selected project

I would like to call an API dynamically depending on which project is called (via slicer). Via a parameter I can control the M-code so that the API is called correctly. However, I would like the parameter to be automatically filled depending on which project you select. Is this somehow possible?

 

 

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous - to make the query dynamic using a M parameter you need to use a Relative Path reference to call the API.  Please see the example in the Power Query documentation.  Web.Contents - PowerQuery M | Microsoft Learn.  So, instead of creating a single string with the full URL path, you need to break into BaseUrl, the relativepath and query.  Something like this:

    BaseUrl = "https://xxxxxx/api",
    RelativePath = "xxxx" & Parameter,
    Query = "xxxx"

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous thanks for your quick message. the API call works flexibly depending on what you put in the parameter. My question now is if I can populate the parameter dynamically depending on what the user selects. I have seen that this works for DirectQuery via "Bind Paramter". However, my source is a REST API and I can't set the storage mode to DirectQuery. Is there any other way to implement this?