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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
f_daniel_souza
Regular Visitor

Implement TestConnection with both Uri.Type plus optional parameter

Hello, I'm trying to create a custom connector for our company Microsoft Purview. We basically use two urls, one to query, which has mandatory json parameter, and another which will receive an entity id directly on url's relative path (executing once per table row). In Power BI Desktop, this connector works wonderfully, however I'm struggling to implement TestConnection. I would like to keep the Uri.Type parameter because of the relative url invocations, however it seems like datasourcepath has a really weird behaviour when trying to set up TestConnection when I need to use both parameters at once.

 

 

7 REPLIES 7
Poojara_D12
Super User
Super User

Hi @f_daniel_souza 

You're building a custom Power BI connector for Microsoft Purview that interacts with two types of endpoints—one that requires a JSON body for querying data, and another that targets a specific entity using an ID embedded in the URL path. While this setup works perfectly in Power BI Desktop, you're running into issues implementing the TestConnection function, which is required for publishing certified connectors and for validating credentials in the Power BI Service. The challenge arises because Power BI expects the dataSourcePath used in TestConnection to be a stable, base URL (like the hostname or a consistent API root) that doesn't contain dynamic elements such as JSON bodies or path parameters. However, your connector uses Uri.Type to handle relative URLs for entity-specific lookups, and combining this with TestConnection causes inconsistencies or validation errors. The recommended approach is to isolate your connector's base URL and use it as the dataSourcePath—ensuring it's static and predictable—while keeping the dynamic parts (like JSON payloads or entity IDs) within individual function logic using RelativePath and Query in Web.Contents. Structuring your connector this way satisfies Power BI’s validation requirements for TestConnection while preserving the flexibility needed for your relative URL invocations.

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS
Akash_Varuna
Super User
Super User

Hi @f_daniel_souza To do the TestConnection with Uri.Type and an optional parameter, ensure the DatasourcePath combines the base URL and parameters logically. Structure TestConnection to match the arguments of your DatasourcePath. Use Record.ToTable to include optional parameters effectively. Test thoroughly with both URL types to ensure compatibility.

Hi @Akash_Varuna, thank you so much for the reply. Do you have any code example representing this scenario? I have already tried several different things, such as parsing the dataSourcePath with Json.Document, or using static values, some of them actually pass the VSCode TestConnection but fail on Power BI Service. I think I've read all Github examples, but none of them covers a Uri.Type + second parameter, so I assumed Microsoft "special handling" of Uri.Type might be causing the problem.

Hi @f_daniel_souza 

Thank you for reaching out to the Microsoft Fabric Forum Community.

 

@Akash_Varuna thank you for your inputs.
@f_daniel_souza -I have attached some official documents below for your reference. They may be helpful, so please take a look.
Gateway Support for Power Query connectors - Power Query | Microsoft Learn
Solved: Custom Connectors - API url + body - Microsoft Fabric Community
Custom API Connector - Data Source Path - Microsoft Fabric Community

Thanks.

Hi @f_daniel_souza 

I hope the information shared was helpful to you. If your question has been answered, kindly mark the most relevant reply as the Accepted Solution. This small action can make a big difference for others who are looking for the same solution.

 

Hi @f_daniel_souza 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.

Hi @f_daniel_souza 

Hope everything’s going smoothly on your end. We haven’t heard back from you, so I wanted to check if the issue got sorted  If yes, marking the relevant solution would be awesome for others who might run into the same thing.

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors