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
Anonymous
Not applicable

On premises Data Gateway Data Source for optional parameters

Hi,

I am trying to use On - premises Data Gateway with my Custom connector, I added Test Connection section in my code:

DemoProject= [TestConnection = (dataSourcePath) =>
let
json = Json.Document(dataSourcePath),
parameter1 = json[parameter1],
parameter2 = json[parameter2],
parameter3 = json[parameter3]
in
{ "DemoProject.Contents", parameter1, parameter2, parameter3},
Authentication = [
UsernamePassword = [
UsernameLabel = "Username",
PasswordLabel = "Password",
Label = "DemoProjectCredentials"
]
],
Label = "DemoProject API"
];

My DemoProject.Contents looks like : 

[DataSource.Kind="DemoProject", Publish="DemoProject.Publish"]
shared DemoProject.Contents = Value.ReplaceType(DemoProjectImpl, DemoProjectType);

DemoProjectType = type function (
parameter1 as (type text meta [
DataSource.Path = false,
Documentation.FieldDescription = "Defines parameter1"
]),
parameter2 as (type text meta [
Documentation.FieldDescription = "Defines parameter2"
]),
optional parameter3 as (type text meta [
Documentation.FieldDescription = "Defines parameter3."
]))
as table meta [
Documentation.Name = "DemoProject"
];

DemoProjectImpl = (parameter1 as text, parameter2 as text, optional parameter3 as text) =>
let
NavigationTables = DemoProjectNavTableQueryFolding(parameter1, parameter2, parameter3)
in
NavigationTables;

1.PNG

When I remove word optional for last parameter and remove DataSource.Path = false, I get 2.PNG

And also in in Gateway logs there is:

GatewayPipelineErrorCode=DM_GWPipeline_UnknownError
GatewayVersion=
InnerType=ValueException
InnerMessage=<pi>[Expression.Error] The field 'parameter1' of the record wasn't found.</pi>
InnerToString=<pi>Microsoft.Mashup.Engine1.Runtime.ValueException: [Expression.Error] The field 'parameter1' of the record wasn't found.
at Microsoft.Mashup.Engine1.Runtime.RecordValue.IndexOf(String field)
at Microsoft.Mashup.Engine1.Runtime.RecordValue.get_Item(String field)......

 

Any ideas why it happens? @artemus

 

2 ACCEPTED SOLUTIONS
artemus
Employee
Employee

I haven't done this too much, but I think if you remove DataSource.Path, you must instead add to your DemoProject record:

MakeResourcePath = (parameter1) => parameter1,
ParseResourcePath = (resource) => { resource },

 

Assuming that parameter1 is the sole determiner of the login context. If you also need other parameters, you can add them to the parameter list, and use something like parameter1 & "/" & parameter2 for the return value. ParseResourcePath does the reverse of what MathResourcePath does, in that if using parameter1 and paramter2, you could have: {Text.BeforeDelimiter(resource, "/"), Text.AfterDelimiter(resource,"/")}

View solution in original post

Anonymous
Not applicable

@artemus Thanks a lot for suggestion, it works

Type = "Singleton",
MakeResourcePath = () => "MyConnector",
ParseResourcePath = (resource) => { },
TestConnection = (resource) => {"() => true"},

View solution in original post

3 REPLIES 3
artemus
Employee
Employee

I haven't done this too much, but I think if you remove DataSource.Path, you must instead add to your DemoProject record:

MakeResourcePath = (parameter1) => parameter1,
ParseResourcePath = (resource) => { resource },

 

Assuming that parameter1 is the sole determiner of the login context. If you also need other parameters, you can add them to the parameter list, and use something like parameter1 & "/" & parameter2 for the return value. ParseResourcePath does the reverse of what MathResourcePath does, in that if using parameter1 and paramter2, you could have: {Text.BeforeDelimiter(resource, "/"), Text.AfterDelimiter(resource,"/")}

Anonymous
Not applicable

@artemus  With DataSource.Path=false we can exclude parameter from datasource path, if I remove it and will add MakeResourcePath = (parameter1) => parameter1,
ParseResourcePath = (resource) => { resource }...does that rule will remain, does parameter will be excluded?

Anonymous
Not applicable

@artemus Thanks a lot for suggestion, it works

Type = "Singleton",
MakeResourcePath = () => "MyConnector",
ParseResourcePath = (resource) => { },
TestConnection = (resource) => {"() => true"},

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

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors