studio
latest
false
- 基本情報
- セットアップと構成
- オートメーション プロジェクト
- 依存関係
- ワークフローの種類
- 制御フロー
- ファイルの比較
- オートメーションのベスト プラクティス
- ソース管理との連携
- デバッグ
- ログ
- 診断ツール
- ワークフロー アナライザー
- ワークフロー アナライザーについて
- ST-DBP-002 - 多数の引数
- ST-DBP-003 - 空の catch ブロック
- ST-DBP-007 - 複数のフローチャートレイヤー
- ST-DPB-010 - [ワークフロー] または [テスト ケース] の複数のインスタンス
- ST-DBP-020 - 未定義の出力プロパティ
- ST-DBP-021 - ハードコードされたタイムアウト
- ST-DBP-023 - 空のワークフロー
- ST-DBP-024 - 永続性アクティビティの確認
- ST-DBP-025 - 変数のシリアル化の前提条件
- ST-DBP-027 - Persistence のベスト プラクティス
- ST-DBP-028 - 引数のシリアル化の前提条件
- ST-USG-005 - ハードコードされたアクティビティのプロパティ
- ST-USG-009 - 未使用の変数
- ST-USG-010 - 未使用の依存関係
- ST-USG-014 - パッケージの制限
- ST-USG-017 - パラメーターの修飾子が無効
- ST-USG-020 - 最小ログ メッセージ
- ST-USG-024 - 未使用で保存されたままの値
- ST-USG-025 - 保存した値の誤用
- ST-USG-026 - アクティビティの制限
- ST-USG-027 - 必要なパッケージ
- ST-USG-028 - ファイル テンプレートの呼び出しの制限
- ST-USG-027 - 必須のタグ
- ST-USG-034 - Automation Hub URL
- 変数
- 引数
- インポートされた名前空間
- コード化されたオートメーション
- トリガーベースの有人オートメーション
- オブジェクト リポジトリ
- ScreenScrapeJavaSupport ツール
- 拡張機能
- Studio でのテスト
- トラブルシューティング
重要 :
このコンテンツの一部は機械翻訳によって処理されており、完全な翻訳を保証するものではありません。
新しいコンテンツの翻訳は、およそ 1 ~ 2 週間で公開されます。

Studio ガイド
最終更新日時 2025年11月26日
This tutorial shows how to connect to a MongoDB Atlas database from your UiPath coded automations. MongoDB Atlas is a fully-managed cloud database service that provides a reliable and scalable database solution without the need for local installations.
Here are the ways to implement the MongoDB connection code:
-
Copy and paste the code into a
CSfile of your target project. -
Use a custom activity package and the sample
NUPKGfile
When opting to use the sample
NUPKG file, you have the capability to add the two-factor authentication as an activity within your XAML files.
Tip: Regardless of whether you choose to integrate the MongoDB connection code in your CS files (for coded automations) or XAML files (for low-code automations), remember that you can invoke a coded automation into a low-code one and vice versa. For more information about hybrid automations, visit Creating hybrid automations - Combining Coded and Low-code Workflows.
- Ensure you have UiPath Studio (version 2024.10 or later - recommended).
- Ensure you have a MongoDB Atlas account.
- Install the
MongoDB.DriverNuGet package in your project.- Open your UiPath project in Studio.
- In the Design ribbon, go to Manage Packages.
- Select All Packages or the .NET tab.
MongoDB.Driverを検索します。- Select
MongoDB.Driver, and then select Install. - Accept the license agreement and dependencies.
To use the MongoDB Atlas connection in your coded automation, you can copy and paste the following sample code in a
CS file from your target project. Make sure the namespace of the file matches with the one of your project name.
Note: The sample code connects to MongoDB Atlas using the connection string format specific to cloud deployments. Make sure to replace the placeholder credentials with your actual MongoDB Atlas credentials.
using System;
using System.Collections.Generic;
using System.Data;
using UiPath.CodedWorkflows;
using UiPath.Core;
using UiPath.Core.Activities.Storage;
using MongoDB.Driver;
namespace MongoDBCodedWorkflowsSample
{
public class TestConnection : CodedWorkflow
{
[Workflow]
public string Execute(string username, string password, string cluster)
{
List<string> databaseNames = new List<string>();
try
{
// Create MongoDB Atlas connection string
string connectionString = $"mongodb+srv://{username}:{password}@{cluster}/?retryWrites=true&w=majority";
Console.WriteLine("Connecting to MongoDB Atlas...");
// Initialize MongoDB client
var client = new MongoClient(connectionString);
// List all databases to verify connection
Console.WriteLine("\nAvailable databases:");
databaseNames = client.ListDatabaseNames().ToList();
foreach (var dbName in databaseNames)
{
Console.WriteLine($"- {dbName}");
}
Console.WriteLine("\nConnection successful!");
}
catch (MongoAuthenticationException authEx)
{
Console.WriteLine($"Authentication error: {authEx.Message}");
Console.WriteLine("Please verify your username and password.");
throw;
}
catch (MongoConnectionException connEx)
{
Console.WriteLine($"Connection error: {connEx.Message}");
Console.WriteLine("Please check your network access settings in MongoDB Atlas.");
throw;
}
catch (Exception ex)
{
Console.WriteLine($"MongoDB connection error: {ex.Message}");
throw;
}
return databaseNames;
}
}
}using System;
using System.Collections.Generic;
using System.Data;
using UiPath.CodedWorkflows;
using UiPath.Core;
using UiPath.Core.Activities.Storage;
using MongoDB.Driver;
namespace MongoDBCodedWorkflowsSample
{
public class TestConnection : CodedWorkflow
{
[Workflow]
public string Execute(string username, string password, string cluster)
{
List<string> databaseNames = new List<string>();
try
{
// Create MongoDB Atlas connection string
string connectionString = $"mongodb+srv://{username}:{password}@{cluster}/?retryWrites=true&w=majority";
Console.WriteLine("Connecting to MongoDB Atlas...");
// Initialize MongoDB client
var client = new MongoClient(connectionString);
// List all databases to verify connection
Console.WriteLine("\nAvailable databases:");
databaseNames = client.ListDatabaseNames().ToList();
foreach (var dbName in databaseNames)
{
Console.WriteLine($"- {dbName}");
}
Console.WriteLine("\nConnection successful!");
}
catch (MongoAuthenticationException authEx)
{
Console.WriteLine($"Authentication error: {authEx.Message}");
Console.WriteLine("Please verify your username and password.");
throw;
}
catch (MongoConnectionException connEx)
{
Console.WriteLine($"Connection error: {connEx.Message}");
Console.WriteLine("Please check your network access settings in MongoDB Atlas.");
throw;
}
catch (Exception ex)
{
Console.WriteLine($"MongoDB connection error: {ex.Message}");
throw;
}
return databaseNames;
}
}
}Connection Parameters
- username: The database user you created in MongoDB Atlas
- password: The password for your database user
- cluster: Your cluster hostname from the connection string (e.g.,
cluster0.abc123.mongodb.net)
The sample returns a list of all databases for that specific set of credentials.
Connection String Format - MongoDB Atlas uses the
mongodb+srv:// protocol, which:
- Automatically discovers all nodes in your cluster
- Provides automatic failover support
- Includes retry logic for write operations (
retryWrites=true) - Sets the write concern to majority (
w=majority)
エラー処理
- MongoAuthenticationException: Occurs when credentials are incorrect
- MongoConnectionException: Occurs when network access is blocked or cluster is unavailable
- General exceptions: Catches any other MongoDB-related errors
Using a sample
NUPKG file enables you to include the two-factor code in your automations.
- Download the
NUPKGfile. - Upload the downloaded
NUPKGfile to your Orchestrator Host or Tenant feed, which are accessible through your Studio instance. For more information on uploading theNUPKGfile as a custom library to Orchestrator, refer to Manually uploading a library to Orchestrator. - Studio プロジェクトを開き、[パッケージを管理] メニューを開きます。
- Search for the
MongoDB.Coded.Workflows.SampleNUPKGfile you previously saved to your Orchestrator Host or Orchestrator Tenant feed, and install it.Figure 1. Custom library in the Manage Packages menu
- After you install the file, navigate to the Activities panel and locate
MongoDB.Coded.Workflows.Sample. Drag and drop the GetDatabases activity into yourXAMLfiles to test your MongoDB connection and fetch a list of the available databases.Figure 2. GetDatabases activity in the Activities panel