Anaplan API Error: The credentials supplied were invalid.

Contributor

Anaplan API Error: The credentials supplied were invalid.

Hello,

 

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.

 

@echo off
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 AnaplanUser="myEmail:myPassword"
set WorkspaceId="8a8194884654c84e01466e6807f07880"
set ModelId="E0FD68F291834D9787D0BC3B3D4A0818"
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
cd %~dp0
if not %AnaplanUser% == "" set Credentials=-user %AnaplanUser%
set Command=.\AnaplanClient.bat %Credentials% -workspace %WorkspaceId% -model %ModelId% %Operation%
@echo %Command%
cmd /c %Command%
pause

 

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?

Message 1 of 8
7 REPLIES 7
Expert

Re: Anaplan API Error: The credentials supplied were invalid.

I can't see anything obviously wrong there. If you set AnaplanUser="" it should prompt you to enter your credentials when you run it - try that and see if you can make it work that way first. Also adding "-d -d" immediately after the .\AnaplanClient.bat will give you more detailed information.
Message 2 of 8
Contributor

Re: Anaplan API Error: The credentials supplied were invalid.

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.

Message 3 of 8
Highlighted
Expert

Re: Anaplan API Error: The credentials supplied were invalid.

Ok. Try with just your username in AnaplanUser now. It should ask for the password only. That might tell us if the username or password is causing the problem.
Message 4 of 8
Expert

Re: Anaplan API Error: The credentials supplied were invalid.

If it is the password, the most likely cause is punctuation characters such as '%', '!' or '^' being interpreted by the Windows CMD interpreter that runs the batch file. Either change the password to one that doesn't contain them or escape the characters by prefixing with a caret ('^') to resolve this.
Message 5 of 8
Contributor

Re: Anaplan API Error: The credentials supplied were invalid.

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!

Message 6 of 8
Contributor

Re: Anaplan API Error: The credentials supplied were invalid.

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.

Message 7 of 8
Certified Master Anaplanner

Re: Anaplan API Error: The credentials supplied were invalid.

@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.

 

Downloading certificates

https://help.anaplan.com/anapedia/Content/GettingStarted/Certificates.htm?_ga=2.123966282.1159404218...

 

Syntax for adding in a certificate (pp. 11-14)

https://s3.amazonaws.com/anaplanenablement/Community/Anapedia/Anaplan_Connect.pdf

 

 

Message 8 of 8