I am working through the Anaplan Connect guide and have run into an issue testing the first import of a .csv file. I'm using the following script stored in a .bat file.
rem This example loads a source text file and runs an Anaplan import into a module.
rem For details of how to configure this script see doc\Anaplan Connect User Guide.doc
set Operation=-file "cleaned_train_data.csv" -put "C:\Users\jmiddleton\Projects\Kaggle Competitions\Titanic" -import "Training Data from cleaned_train_data.csv" -execute -output "C:\Users\jmiddleton\Projects\Kaggle Competitions\My Errors.txt"
rem *** End of settings - Do not edit below this line ***
setlocal enableextensions enabledelayedexpansion || exit /b 1
if not %AnaplanUser% == "" set Credentials=-user %AnaplanUser%
set Command=.\AnaplanClient.bat %Credentials% -workspace %WorkspaceId% -model %ModelId% %Operation%
cmd /c %Command%
When running this script I get an error returned stating "Anaplan API: The credentials supplied were invalid."
I've confirmed that the Workspace and Model ID's are correct as well as my personal login credentials.
Is there something I might be missing in the script or configured the script incorrectly in some way?
Thanks Ben - I'll try running the batch file again with "-d -d" to see if it'll output a more specific error.
I've been able to get the batch file to run properly when I delete the "myPassword" section of the AnaplanUser variable. Doing this does get the command prompt to request my credentials but I was hoping to be able to store my credentials in the batch file so that it could run without user interaction being required.
When I remove the password field following the ':' in the AnaplanUser variable then the CMD prompt does request my password. From there the rest of the batch file performs as expected.
But I still need to get this to work without that prompt. I've tried escaping the exclamation mark in the password argument with a caret '^!' and double-carets '^^!' - neither of those escape patterns work but they do return some interesting errors.
Escaping with a single caret (e.g. set AnaplanUser="myUsername@email.com:myPassword7777^!"):
A workspace ID must be provided
An import, export, action or process must be specified before -execute
No dumpfile is available
Escaping with a double-caret (e.g. set AnaplanUser="myUsername@email.com:myPassword7777^^!"):
The credentials supplied were invalid.
The when including the -d -d parameter for more details, the first pattern doesn't show much activity before erroring out. The second escape pattern shows that the file staging and upload to the server is occurring but still erroring out when checking the credentials.
I suspect the issue is still stemming from the "!" in the password argument and that the standards for escaping special characters isn't working exactly as expected due to the fact it's encase in a string and stored in a variable.
I'm going to keep fiddling with the escape pattern as exclamation marks are a frequently occurring character in passwords and understanding proper escaping of characters like these would be beneficial for clients.
When I come across a working solution I'll post it to this thread.
Thanks again Ben!
I've come across some additional details while attempting to debug this issue. It would seem the reason the "!" is causing problems in the .bat script is due to the way special characters are handled when EnableDelayedExpansion is active in the shell running the script.
EnableDelayedExpansion changes the way special characters have to be handled and the "!" character is especially problematic since it's used in CMD.exe to denote a variable when EnableDelayedExpansion is active.
Still haven't found a way to work around this limitation directly within the .bat script yet.
@JMiddleton I've found using certificates to be very easy to use; you may already be familair with how to use them. They take just a couple of of minutes to download and set up.
Syntax for adding in a certificate (pp. 11-14)