How to Troubleshoot Adding a Data Source in Power Apps (PAC CLI Guide)

How to Troubleshoot Adding a Data Source in Power Apps (PAC CLI Guide)

Struggling to add a data source in Power Apps using the PAC CLI (Power Apps Command Line Interface)? You're not alone. Data source connection errors are among the most common friction points developers face when building code-first apps on the Power Platform. This step-by-step troubleshooting guide will help you identify the root cause and get back on track — fast.

Whether you're a seasoned developer or just getting started with Power Platform development, the tips below cover the most frequent issues encountered with the pac code add-datasource command and how to resolve them.


What Is the PAC CLI Data Source Command?

The pac code add-datasource command is part of the Power Apps Command Line Interface (PAC CLI) toolset. It allows developers to connect data sources — such as Dataverse tables, SharePoint lists, or other connectors — directly to code-based Power Apps during development.

When this command fails, it can block your entire development workflow. Below are the most common causes and their solutions.


Common Errors When Adding a Data Source

1. Authentication or Authorization Failures

One of the most frequent causes of failure is an expired or missing authentication token.

2. Incorrect Environment Selected

The PAC CLI operates against a specific Power Platform environment. If the wrong environment is selected, the data source connection will fail.

3. Missing or Outdated PAC CLI Version

Using an outdated version of the PAC CLI can introduce compatibility issues with newer Power Platform features.

4. Invalid or Unavailable Data Source

The data source you are attempting to add may not exist in the selected environment, or the connector may not be available.

5. Network or Proxy Issues

Corporate firewalls or proxy configurations can interrupt PAC CLI communication with Power Platform endpoints.


Step-by-Step Troubleshooting Checklist

Follow this checklist to systematically diagnose and resolve data source issues in PAC CLI:


Understanding PAC CLI Error Codes

When the pac code add-datasource command fails, the CLI typically returns an error code. Here are the most common ones:


Related Power Platform Resources

If you're building code-first apps and running into broader development challenges, explore these resources:


Still Stuck? We Can Help.

If you've worked through the steps above and are still experiencing issues adding a data source in Power Apps, the CRMONCE team of certified Power Platform specialists is here to help. From environment configuration to complex data source integrations, we've solved it all.

Don't let a data source error derail your project. Contact our Power Platform experts today for a free consultation, or explore our consulting services to see how we can accelerate your Power Apps development.

Get Expert Help Now →