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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

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.

1 ACCEPTED SOLUTION
mahoneypat
Employee
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





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

5 REPLIES 5
mahoneypat
Employee
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





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.

kasarrumann_1-1596217013754.png

 

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:

kasarrumann_0-1596216979425.png

 

 

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.

Hi @Anonymous 

Is this problem sloved? 

If it is sloved, could you kindly accept it as a solution to close this case and help the other members find it more quickly?

If not, please feel free to let me know.

 

Best Regards

Maggie

Anonymous
Not applicable

Hi Maggie, it wasnt resolved unfortunately. 

 

I can't have a table of all different customers URLs displayed even though that would solve the problem here. 

 

My connector is a navigator which also holds nested functions similar to this example pseudo code:

 

 

shared Navtable.Contents = (userURL) as table =>
    let 
        Source = Json.Document(Web.Contents(URL & "Some path that lists api", Headers etc)
        createNavtable here
        table#(CreateNestedNavtable)
    in
        Navtable;


CreateNestedNavTable = () as table =>
    let
        objects = #table(
            {"Name", "Key","Data",               "ItemKind", "ItemName","IsLeaf"},{
            {"Item1", "item1", #table({"Column1"}, {{rows}), "Table", "Table",   true},
            {"myFunc", "func1", myFunction(), "Function",    "Function",    true}
        }),
        NavTable = Table.ToNavigationTable(objects, {"Key"}, "Name", "Data", "ItemKind", "ItemName", "IsLeaf")
    in
        NavTable;

myFunction = () =>
    let 
       Source = Json.Document(Web.Contents(URL** & "Some other path"))
       **get the URL parameter value which was required from Navtable.Contents(URL) which is 
       now stored, 
       as DataSourcePath for that query through M code instead of a new myFunction = (URL) 
       parameter. Is there anything similar to Extention.CurrentCredential()[Username] for a 
       queries' DataSourcePath metadata?
    in
       myFunctionResult
       

 

 

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.

Capture1.JPG

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.

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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