Vault API Login Problem

Vault API Login Problem

Marco.Vasconcelos
Explorer Explorer
928 Views
1 Reply
Message 1 of 2

Vault API Login Problem

Marco.Vasconcelos
Explorer
Explorer

Hello, everyone! I am trying to do my first steps with Vault API via PowerShell but now I'm stuck and would very much appreciate your help. When I run the code I receive a error 404: New-Object : Exception calling ".ctor" with "1" argument(s): "The remote server returned an error: (404) Not Found."

 

I tried many modifications and tested and different machines but I'm now completely lost on what the problem could be.

 

Following is my current code (Vault 2023):

 

 

 

[System.Reflection.Assembly]::LoadFrom("C:\Program Files\Autodesk\Vault Client 2023\Explorer\Autodesk.Connectivity.WebServices.dll")

$cdnVaultServer="<ServerIP>"
$cdnVaultName="Vault"
$cdnVaultUser="Administrator"
$cdnVaultUserPsw="<Password>"
$cdnVaultReadOnly= $false

$licenseAgent = [Autodesk.Connectivity.WebServices.LicensingAgent]::Client

$mServer = New-Object Autodesk.Connectivity.WebServices.ServerIdentities
$mServer.DataServer = $cdnVaultServer
$mServer.FileServer = $cdnVaultServer

$cdnCredentials = New-Object Autodesk.Connectivity.WebServicesTools.UserPasswordCredentials ($mServer, $cdnVaultName, $cdnVaultUser, $cdnVaultUserPsw, $licenseAgent)

$cdnVault = New-Object Autodesk.Connectivity.WebServicesTools.WebServiceManager($cdnCredentials)

$cdnWebServiceManager.AdminService.GetAllUsers()

 

 

 

0 Likes
929 Views
1 Reply
Reply (1)
Message 2 of 2

Markus.Koechl
Autodesk
Autodesk

You are missing an important step: copy the licensing dll into the PowerShell directory. Find the detail in the note of my code template below.

To get started with Powershell for Vault, I recommend two AU classes:

Autodesk Vault 2020—Programming 101 | Autodesk University and Feel the Power Between Vault and PowerShell | Autodesk University.

The class targeted Vault 2020, but the code below matches 2023.

#region disclaimer
	#===============================================================================
	# PowerShell script sample														
	# Author: Markus Koechl															
	# Copyright (c) Autodesk 2021													
	#																				
	# THIS SCRIPT/CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER     
	# EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES   
	# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.    
	#===============================================================================
#endregion

#region ConnectToVault

		# NOTE - click licensing v6 requires to copy AdskLicensingSDK_6.dll to PowerShell execution folder C:\Windows\System32\WindowsPowerShell\v1.0 before Powershell runtime starts

		[System.Reflection.Assembly]::LoadFrom('C:\Program Files\Autodesk\Autodesk Vault 2023 SDK\bin\x64\Autodesk.Connectivity.WebServices.dll')
		$serverID = New-Object Autodesk.Connectivity.WebServices.ServerIdentities
			$serverID.DataServer = "<ServerName or IP>"
			$serverID.FileServer = "<ServerName or IP>"
		$VaultName = "<Name of Vault>"
		$UserName = "<User Name>"
		$password = "<Password>"
		#Select license type by licensing agent enum "Client" (=Named User) "Server" (= (legacy) Multi-User) or "None" (=readonly access) or "Token" (Autodesk ID)
		$licenseAgent = [Autodesk.Connectivity.WebServices.LicensingAgent]::Client
		
		$cred = New-Object Autodesk.Connectivity.WebServicesTools.UserPasswordCredentials($serverID, $VaultName, $UserName, $password, $licenseAgent)
		$vault = New-Object Autodesk.Connectivity.WebServicesTools.WebServiceManager($cred)

		#region ExecuteInVault

			#query vault, download files, etc....		
			
		#endregion ExecuteInVault
		
		$vault.Dispose() #don't forget to release the connection, to return the (server) license you also can log out: $cred.SignOut($vault.AuthService, $vault.WinAuthService)


#endregion ConnectToVault

Hope this helps.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes