cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

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

Accepted Solutions
Highlighted
Microsoft
Microsoft

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

Highlighted

@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
Highlighted
Microsoft
Microsoft

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

Highlighted

@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?

Highlighted

@artemus Thanks a lot for suggestion, it works

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

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Community Conference

Microsoft Power Platform Communities

Check out the Winners!

secondImage

Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors
Top Kudoed Authors