Anaplan Connect Batch Script Error: "Anaplan API: The Credentials supplied were invalid"

Hello,

 

I am trying to set up a certificate to run my batch scripts instead of having my username and password included in the batch scripts.  I have confirmed that the batch script works when including my username, and then manually typing in my password; however, when I replace the information with a new certificate that I just created today, I get the following error message:

 

"Anaplan API: The Credentials supplied were invalid."

 

In the command prompt window, this error happens right after the following:

"Using C:\Users\jprince\Desktop\anaplan-connect-1-3-3-3\anaplan-connect-1-3-3-3.jar"

 

Here is the script text I am using in the batch script:

 

@echo off

set AnaplanUser="C:\Users\jprince\Desktop\anaplan-connect-1-3-3-3\certificate-260963260461973179890353199737974574378.cer"
set WorkspaceId="8a81b09d5abf5098015af2e09a942669"
set ModelId="057E8A4AB3A142A58D4EBF7EC3D4C526"
set Operation=-file "Inventory Report - Australia January 2017_FG Detail.csv" -put "C:\Users\jprince\Desktop\anaplan-connect-1-3-3-3\0. Current Batch\Inventory Report - Australia January 2017_FG Detail.csv" ^ -import "** Import Australia Finished Goods" -execute -output "C:\Users\jprince\Desktop\anaplan-connect-1-3-3-3\0. Current Batch\0. Current errors files\Australia Finished Goods Errors.csv"

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

 

 

Is there something wrong with my syntax?  Or my certificate?

Best Answer

  • jprince
    Answer ✓

    I think I figured it out.  It had to do with my syntax at the bottom of the script.  Once I changed it to:

     

    setlocal enableextensions enabledelayedexpansion || exit /b 1

    cd %~dp0

    if not %AnaplanUser% == "" set Credentials=-certificate %AnaplanUser%

    set Command=.\AnaplanClient.bat %Credentials% -workspace %WorkspaceId% -model %ModelId% %Operation%

    @echo %Command%

    cmd /c %Command%

     

    it worked!!

Answers

  • Hi - I'm glad you solved it, but it is not recommended to change the settings below the line.

    To use the certificate, you should to put the following after the operation statement

     

    Operation=-certificate "certificate location.cer" - file ..... -put etc..

     

    Happy Anaplanning

     

     

     

  • Let us know if you need any additional help--Quin and I are experts on Anaplan Connect.

     

    But as David suggested, do not edit below the line, you can cause unexpected changes to the code.

  • Hi!

     

    I'm getting this same error, but just using standard sign-in credentials (I've tested 2 different admin credentials at this point, getting the same error). Any suggestions for de-bugging? (background: using parallels with windows 10 and java 8).

  • Hi Sarah,

     

    If you post your script on the forum it will be easier for people to validate the error. Just remember to put a dummy username and password in before posting.

     

    Without looking at the script I would recommend checking the following:

     

    Set User Syntax

    The syntax should be as below:

    set AnaplanUser = "example.user@company.com:password"

     

    Often I see that the escape characters (") are missing so you have something like this:

    set AnaplanUser = example.user@company:password

     

    Programme Syntax

    The next one to check is that you haven't picked up an example script that has an invalid command syntax (in the lower half of your script

     

    Make sure that the set Credentials is -user %AnaplanUser% and has not been amended. Also check that your .bat file looks something like the below.

     

    I have seen instances where the wrong example file has been used (namely the certificate authentication on) and this has a different operation to the standard authentication methods.

     

    setlocal enableextensions enabledelayedexpansion || exit /b 1
    cd %~dp0
    if not %AnaplanUser% == "" set Credentials=-user %AnaplanUser%
    set Command=.\AnaplanClient.bat %Credentials% -workspace %WorkspaceId% -model %ModelId% -views %Operation%
    @echo %Command%
    cmd /c %Command%
    pause

  • I am getting the following error and don't know how to fix it:

     

    I am not sure what exactly is supposed to be written before the execute line " "Import the organization" -execute "  I just typed something in here.  

     

     

     

     

    .\AnaplanClient.bat -workspace "8a81b09c5a0b3bb4015a87e364ca463f" -model "FA928CA85C07497E909C81426A86685B" -certificate "C:\Users\valerial\anaplan-connect-1-3-3-5\certificate-263675408418392071795596372780932502757.cer" -file "Organization.txt" -put "C:\Users\valerial\anaplan-connect-1-3-3-5\Organization.txt" -import "Import the organization" -execute -output "c:\Users\valerial\anaplan-connect-1-3-3-5\My Errors.txt"
    Using C:\Users\valerial\anaplan-connect-1-3-3-5\anaplan-connect-1-3-3-5.jar
    The file "C:\Users\valerial\anaplan-connect-1-3-3-5\Organization.txt" has been uploaded as Organization.txt.
    Import "Import the organization" not found in workspace 8a81b09c5a0b3bb4015a87e364ca463f, model FA928CA85C07497E909C81426A86685B
    An import, export, action or process must be specified before -execute
    No dump file is available.
    Press any key to continue . . .

  • I am getting the following error and don't know how to fix it:

     

    I am not sure what exactly is supposed to be written before the execute line " "Import the organization" -execute "  I just typed something in here.  

     

    .\AnaplanClient.bat -workspace "8a81b09c5a0b3bb4015a87e364ca463f" -model "FA928CA85C07497E909C81426A86685B" -certificate "C:\Users\valerial\anaplan-connect-1-3-3-5\certificate-263675408418392071795596372780932502757.cer" -file "Organization.txt" -put "C:\Users\valerial\anaplan-connect-1-3-3-5\Organization.txt" -import "Import the organization" -execute -output "c:\Users\valerial\anaplan-connect-1-3-3-5\My Errors.txt"
    Using C:\Users\valerial\anaplan-connect-1-3-3-5\anaplan-connect-1-3-3-5.jar
    The file "C:\Users\valerial\anaplan-connect-1-3-3-5\Organization.txt" has been uploaded as Organization.txt.
    Import "Import the organization" not found in workspace 8a81b09c5a0b3bb4015a87e364ca463f, model FA928CA85C07497E909C81426A86685B
    An import, export, action or process must be specified before -execute
    No dump file is available.
    Press any key to continue . . .

  • Normally import names look like "target from source" so I'd expect the import name to end with "from Organization.txt", unless it has been renamed. Try running

    .\AnaplanClient.bat -certificate "C:\Users\valerial\anaplan-connect-1-3-3-5\certificate-263675408418392071795596372780932502757.cer" -workspace "8a81b09c5a0b3bb4015a87e364ca463f" -model "FA928CA85C07497E909C81426A86685B" -imports

    and looking for your import. If the import is in the model but not in the list, check that the user associated with the certificate either is an admin user or belongs to a role that has access to run the import.

  • Thanks! I got the following batch to run but I would like to understand the difference between these two scripts:

     

    They end differently and the 2nd example says set anaplanuser.  What are the different purposes of these? They both run.  

    Example 1)

    @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 WorkspaceId="8a81b09c5a0b3bb4015a87e364ca463f"
    set ModelId="FA928CA85C07497E909C81426A86685B"
    set Operation= -certificate "C:\Users\valerial\anaplan-connect-1-3-3-5\certificate-263675408418392071795596372780932502757.cer" -file "Organization.txt" -put "C:\Users\valerial\anaplan-connect-1-3-3-5\Organization.txt" -import "Organization from Organization.txt" -execute -output "c:\Users\valerial\anaplan-connect-1-3-3-5\My Errors.txt"


    rem *** End of settings - Do not edit below this line ***

    setlocal enableextensions enabledelayedexpansion || exit /b 1
    cd %~dp0
    set Command=.\AnaplanClient.bat -workspace %WorkspaceId% -model %ModelId% %Operation%
    @echo %Command%
    cmd /c %Command%
    pause

     Example 2)

     

    @echo off

     

     

    set AnaplanUser="S:\Accounting\Monthly Files\Anaplan\anaplan-connect-1-3-3-3\anaplan-connect-1-3-3-3\certificate-128126988173629383559428304466628327280.cer"

    set WorkspaceId="8a81b09c603d3463016120314c1869fc"

    set ModelId="4A97F091F5D541438F86363A55FAAE89"

    set Operation=-file "BCUS-ACTUAL" -jdbcurl "jdbc:sqlserver://srvw1056.lvmh-pc.lvmh" -jdbcuser "ReadonlyBEN:8w4mkjW3C" -jdbcquery "SELECT [DATAAREAID] + [DIMENSION2_] + [DIMENSION3_] + [DIMENSION4_] + [ACCOUNTNUM] + [DIMENSION8_] + [DIMENSION7_] + [DIMENSION5_] + [DIMENSION6_] AS 'Row ID',CONVERT(VARCHAR(10), DATEADD(mm, DATEDIFF(m,0,GETDATE()),0), 101) AS 'Date','Actual' AS 'Version',[DATAAREAID] AS 'Company code',[DIMENSION2_] AS 'Market code' ,[DIMENSION3_] AS 'Cost Center' ,[DIMENSION4_] AS 'Customer accounts' ,[ACCOUNTNUM] AS 'GL account',[DIMENSION8_] AS 'Syrus code' ,'' AS 'Tranaction text','' AS 'Currency','' AS 'Amount Currency' ,CAST(SUM([DEBITMST]+ [CREDITMST]) AS CHAR) AS 'Amount',[DIMENSION7_] AS 'Project code' ,[DIMENSION5_] AS 'Category' ,[DIMENSION6_] AS 'Commercial Line' FROM [PCIS_AX2009_BEN].[dbo].[LEDGERBALANCESDIMTRANS] WHERE DATAAREAID = 'BCUS' AND PERIODCODE = '1' AND TRANSDATE >= DATEADD(mm, DATEDIFF(m,0,GETDATE()),0) AND TRANSDATE < DATEADD(mm, DATEDIFF(m,0,GETDATE())+1,0) GROUP BY [DATAAREAID],[DIMENSION2_],[DIMENSION3_],[DIMENSION4_],[ACCOUNTNUM],[DIMENSION8_],[DIMENSION7_],[DIMENSION5_],[DIMENSION6_]" -import "2. Update P&L structure with actuals BCUS" -execute -output "S:\Accounting\Monthly Files\Anaplan\anaplan-connect-1-3-3-3\anaplan-connect-1-3-3-3\1. Error\BCUS Structure Actuals CM Errors.csv"

     

    rem *** End of settings - Do not edit below this line ***

     

    setlocal enableextensions enabledelayedexpansion || exit /b 1

    cd %~dp0

    if not %AnaplanUser% == "" set Credentials=-certificate %AnaplanUser%

    set Command=.\AnaplanClient.bat %Credentials% -workspace %WorkspaceId% -model %ModelId% %Operation%

    @echo %Command%

    cmd /c %Command%

    pause

     

    Thanks,

    Valeria