Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Access the stringvalue of DataSourcePath

So after typing an Api URL(e.g https://api.myapi.com) in the  BaseUrl parameter of my custom data connector, is it possible to fetch that string value programatically?

 

Was hoping for a similar method such as Extension.CurrentCredential()[Username] so I can still get the value in other functions outside of the context where the URL parameter is provided. 

 

Appreciate any help.

  • Yes.  You could start with a table that has a column with your URL(s).  You can then do Web.Contents([URL Column]), or concatenate it into a more complex URL.  Once you expand the result table, you would still have the URL on every row in that original column.

     

    Another way would be to store your URL in a parameter, use it in your web call.  You can then make a separate query that simply equals the parameter value.

     

    If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

    Regards,

    Pat

5 Replies

  • mahoneypat's avatar
    mahoneypat
    Microsoft Employee

    Yes.  You could start with a table that has a column with your URL(s).  You can then do Web.Contents([URL Column]), or concatenate it into a more complex URL.  Once you expand the result table, you would still have the URL on every row in that original column.

     

    Another way would be to store your URL in a parameter, use it in your web call.  You can then make a separate query that simply equals the parameter value.

     

    If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

    Regards,

    Pat

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for your reply Pat, Im new to PowerBI and Custom Data Connectors so I'll dig in to your reply. Just to make sure we understand each other and what Im trying to achive.

       

      I want to extract the DataSourcePath value marked in blue in my Visual Studio project programatically so I can use it a non delayed function as the example from:

       

       

      let
             objects = #table(
                  {"Name",  "Key",                    "Data",                   "ItemKind", "ItemName", "IsLeaf"},{
                  {"myFunction", "function1", someFunction(_url), "Function", "Function",    true}
              }),
              NavTable = Table.ToNavigationTableFunctions(objects, {"Key"}, "Name", "Data", "ItemKind", "ItemName", "IsLeaf") 
          in
              NavTable;

       

      Providing the URL to the someFunction() function as argument forces the function to evaluate as soon as you navigate to it, so that didn't work.

       

      The goal is to avoid forcing users having to type the base URL path once again for the function in the Nav table, and instead use the same one provided to the connector from the start. Then create more complex URLs from other inputs.

       

      Thanks for your help.

      • v-juanli-msft's avatar
        v-juanli-msft
        Community Support

        Hi Anonymous 

        If you'd like to hold some fix and base url and let uses to select other parameters to form a complex url based on the base url, 

        As mahoneypat suggested, you could create parameters to use in the url parts below.

        Best Regards
        Maggie
        Community Support Team _ Maggie Li
        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.