Connect to Python and Powerbi

Hi there, i am using UiPath studio where i want to run python quote and refresh powerbi? How should i go about my connecting them.

Hi @mark_rajkumar1

Step 1: Prepare Your Python Script

  • Ensure your Python script is working independently.
  • It should be saved locally or accessible via a known path.
  • If it generates data for Power BI, save the output to a file (e.g., CSV, Excel, or database).

Step 2: Install UiPath Python Activities

  • In UiPath Studio:
    • Go to Manage Packages.
    • Search for UiPath.Python.Activities and install it.
  • This package allows you to:
    • Load Python scripts
    • Invoke Python methods
    • Run Python code inline

Step 3: Use Python Scope in UiPath

  • Drag the Python Scope activity into your workflow.
  • Set the path to your Python executable (e.g., python.exe).
  • Inside the scope, use:
    • Load Python Script or Invoke Python Method
    • Pass parameters if needed

Step 4: Refresh Power BI Report

You have two main options:

Option A: Use Power BI REST API

  • Register an app in Azure Active Directory to get access tokens.
  • Use HTTP Request activity in UiPath to call:
    • POST https://api.powerbi.com/v1.0/myorg/groups/{group_id}/reports/{report_id}/Refresh
  • You’ll need:
    • Client ID
    • Tenant ID
    • Client Secret
    • Report and Workspace IDs

Option B: Use Power BI Desktop with UI Automation

  • If you’re using Power BI Desktop, you can:
    • Open the .pbix file using Start Process
    • Use Click, Send Hotkey, or Type Into to trigger refresh
    • Save and close the report

Follow above steps and let me know your result.
If these steps solves your query kindly close this case by marking as solution.

Happy Automation!

1 Like

Hi @mark_rajkumar1

Use Python Activities in UiPath to run your Python script, then call Power BI REST API to refresh the dataset using HTTP Request activity.
For more check below link-

If you found helpful, Mark as a solution tick .
Happy Automation