Request

Response

    Connector API

    The ConnectorAPI class provides methods and events to manage Autodesk Data Exchanges via the Connector UI layer, enabling integration with the DataExchange service. It acts as a bridge between the UI and the underlying data exchange functionalities, supports create, update, delete, load, unload, and utility actions such as copy/view/share exchanges.

    Key Components

    Following are the keys components of the ConnectorAPI.

    • Constructor

      Constructor: Accepts an Application instance to initialize the Connector.

          var application = new Application(...);
          var connectorAPI = new ConnectorAPI(application);
      
    • Events

      Following are the events available in the ConnectorAPI:

      • ConnectorClosed: Triggered when the connector is closed.
      • ExchangesLoaded: Triggered when exchanges are loaded in the connector.
          // Subscribe to events
          connectorAPI.ConnectorClosed += (sender, e) => { /* Handle connector closed */ };
          connectorAPI.ExchangesLoaded += (sender, e) => { /* Handle exchanges loaded */ };
      

    SuppressUIArgs Class

    SuppressUIArgs is an abstract base class used to suppress UI prompts during certain operations, DeleteExchangeSuppressUIArgs, is used to manage arguments for suppressing certain UI prompts in an application.

    • Base Class: SuppressUIArgs

      SuppressUIArgs is an abstract class that serves as a base for other classes needing to provide arguments to suppress UI prompts. As an abstract class, it cannot be instantiated directly. Instead, it is intended to be inherited by other classes that will provide specific implementations.

          //// <summary>
          /// It serves as a common base for classes that provide arguments for suppressing certain UI prompts.
          /// </summary>
          public abstract class SuppressUIArgs
          {
          }
      
    • Derived Class: DeleteExchangeSuppressUIArgs

      The DeleteExchangeSuppressUIArgs class inherits from SuppressUIArgs and provides specific arguments to suppress UI prompts during a “Delete Exchange” operation.

      In the following code block, ShowConfirmationMessage is a boolean property that indicates whether a confirmation message box should be shown when performing the delete operation. The constructor initializes ShowConfirmationMessage to true, meaning that by default, the confirmation message will be shown unless explicitly set otherwise.

          /// <summary>   
          /// This class contains arguments that can be specified to suppress UI prompts when Delete Exchange is called
          /// </summary>
          public class DeleteExchangeSuppressUIArgs : SuppressUIArgs
          {
              /// <summary>
              /// Property to indicate whether a confirmation message box should be displayed when deleting.
              /// </summary>
              public bool ShowConfirmationMessage { get; set; }
      
              public DeleteExchangeSuppressUIArgs()
              {
                  this.ShowConfirmationMessage = true;
              }
          }
      
          var deleteExchangeSuppressUIArgs = new  DeleteExchangeSuppressUIArgs
          {
              ShowConfirmationMessage = false
          };
      
          connectorAPI.AddSuppressUIArgs( deleteExchangeSuppressUIArgs);
      
      Show More

      These classes are likely used in scenarios where certain UI interactions, such as confirmation dialogs, need to be suppressed based on user preferences or specific conditions. For example, when performing batch operations or automated tasks, it might be necessary to suppress these prompts to ensure smooth execution without manual intervention.

      Example

      In a method designed to perform a delete operation, you will typically encounter the following steps:

          public void DeleteExchange(ExchangeItem exchangeItem)
          {
              var args = connectorAPI.GetSuppressUIArgs<DeleteExchangeSuppressUIArgs>();
              if (args.ShowConfirmationMessage)
              {
                  // Show confirmation dialog
              }
              else
              {
                  // Proceed with deletion without confirmation
              }
          }   
      
      Show More

      This allows the method to conditionally show or suppress the confirmation dialog based on the provided arguments.

    In summary, SuppressUIArgs and its derived classes provide a flexible way to control UI behavior in different parts of an application, enhancing user experience and automation capabilities.

    UI API Methods

    The following are various important methods offered by the Connector UI API:

    • CreateExchange: Creates a new data exchange.

      // Create a new exchange
      var exchangeItem = await connectorAPI.CreateExchange("New exchange name", "folderId", "projectId", "hubId");
      
    • UpdateExchange: Updates an existing data exchange.

      var exchangeItem = await connectorAPI.UpdateExchange("Exchange name/id");
      
    • DeleteExchange: Deletes a specified data exchange.

      connectorAPI.DeleteExchange("Exchange name/id");
      
    • LoadExchange: Loads a specified data exchange.

      var dataExchangeIdentifier = new DataExchangeIdentifier
      {
          CollectionId = "CollectionId",
          ExchangeId = "ExchangeId",
          HubId = "HubId"
      }; 
      
      var exchangeItem = await connectorAPI.LoadExchange(dataExchangeIdentifier);
      
      Show More
    • LoadLatestExchange: Synchronizes a loaded exchange with the latest version from the cloud. Use this when another team member has published updates to an exchange you’re currently working with. The method refreshes the exchange data while preserving local view settings and visibility state.

      // Update exchange with latest cloud changes
      await connectorAPI.LoadLatestExchangeAsync("Exchange name/id");
      

      When to use:

      • After receiving notification that the exchange has been updated by another user
      • Before making your own changes to ensure you’re working with the latest version
      • Periodically in long-running sessions to stay synchronized with team updates

      Important: LoadLatestExchange does not preserve uncommitted local changes. Always publish or save your work before updating to the latest version to avoid data loss.

      See Working with Exchange Updates for collaboration best practices and multi-user workflow patterns.

    • UnloadExchange: Unloads a specified data exchange.

      connectorAPI.UnloadExchange("Exchange name/id");
      
    • SelectElements: Selects elements belonging to specified data exchanges.

      var exchangeNames = new List<string>
      {
          "ExchangeName1",
          "ExchangeName2",
      };
      connectorAPI.SelectElements(exchangeNames);
      
    • CopyExchangeLink: Copies the link of a specified data exchange.

      connectorAPI.CopyExchangeLink("Exchange name/id");
      
    • ViewExchange: Views a specified data exchange.

      connectorAPI.ViewExchange("Exchange name/id");
      
    • GetNotifications: Returns all notifications.

      List<Notification> notifications = connectorAPI.GetNotifications();
      
    • GetExchangeItem: Returns details of a specified data exchange.

      connectorAPI.GetExchangeItem("ExchangeName");
      
    • GetExchanges: Returns all data exchanges.

      IEnumerable<ExchangeItem> exchanges = connectorAPI.GetExchanges();
      
    • CloseConnector: Closes the connector window.

      connectorAPI.CloseConnector();
      

    Use ConnectorAPI Class in your Application

    Following is an example how you can use the ConnectorAPI class in your application.

       var application = new Application(...);
       var connectorAPI = new ConnectorAPI(application);
       
       // Subscribe to events
       connectorAPI.ConnectorClosed += (sender, e) => { /* Handle connector closed */ };
       connectorAPI.ExchangesLoaded += (sender, e) => { /* Handle exchanges loaded */ };
       
       // Create a new exchange
       var exchangeItem = await connectorAPI.CreateExchange("New Exchange", "folderId", "projectId", "hubId");
       
       // Get all exchanges
       var exchanges = connectorAPI.GetExchanges();
       
       // Close the connector
       connectorAPI.CloseConnector();
    
    Show More