How to export result as .csv file through Anaplan Connect script?

Hi Experts,

I'm trying to explore on Transactional APIs scripting. When I execute below script is working fine and extracting all the List items. But I want to export this data as .csv file, how to achieve this?

set Operation=-debug -service %ServiceUrl% -auth %AuthUrl% -workspace %WorkspaceId% -model %ModelId% -L

 

anildudam_2-1667315136773.png

I tried with below code, but it's not creating any file. 

 

set Operation=-debug -service %ServiceUrl% -auth %AuthUrl% -workspace %WorkspaceId% -model %ModelId% -L -execute –get:csv %OutputPath%

 

anildudam_0-1667314976580.png

 

Seems I'm doing some thing wrong. Kindly help me here.

Thanks & regards,

Anil

Answers

  • StevenBeerthuizen
    edited November 2022

    Hi Anil,

    As far as I can see in the documentation, the -get is used for getting an export file from an export action. Not just exporting anything from the operation you define. But i do not know Anaplan Connect that well. It might also help if you change the subject title to "How to export result as .csv file through Anaplan Connect script?", because it does make a difference if you use Anaplan Connect or the Transactional API directly.

    Kind regards,

    Steven

  • anildudam
    edited November 2022

    Hi Steven,

    Thanks for your reply.

     

    as per your suggestion I have changed the subject title.

    Still waiting for the solution from expects.

    Thanks & regards,

    Anil

  • ManjunathKN
    edited November 2022

    Hi Anil,

     

    I am no expert in pulling transactional API from anaplan connect. it seems that you are missing the List ID to execute the operation

     

    Add 

    set ListId="listid"

     and use operation

    set Operation=-debug -service %ServiceUrl% -auth
    %AuthUrl% -workspace %WorkspaceId% -model %ModelId% -l %ListId% -execute -get:csv %FilePath%

     

    Let me know if this helps.

     

    Thanks,
    Manjunath

  • ManjunathKN
    edited November 2022

    @anildudam 

     

    didnt help? are you thinking of exporting the List ids and names? I am not sure you can do that, Transactional APIs will only work to do operations at granular level. As far i understand we can do pick and execute in Transactional API. 

     

    @ryan_kohn can we export the Display of Lists and IDs?

    Thanks,
    Manjunath

  • @ManjunathKN Indeed if you use the Transactional API directly, and not Anaplan Connect you can just use this call and use the json response to do whatever you want: 

     

    curl -X GET 'https://api.anaplan.com/2/0/workspaces/{workspaceId}/models/{modelId}/lists' \ -H 'Accept: application/json' \ -H 'Authorization: AnaplanAuthToken {anaplan_auth_token}'

     

    For this call there is no 'Accept: text/csv' option, so i guess that Anaplan Connect also is not able to get it in csv format. 

  • Hi @StevenBeerthuizen 

     

    Thanks for further clarification! So in both(REST API and Anaplan Connect) case I believe it can call but it cannot download into CSV.

     

    Regards,
    Manjunath

  • ryan_kohn
    edited November 2022

    @anildudam @ManjunathKN Anaplan Connect (version 3 and up) supports exporting a model's list details (ID's and Names). Example command below.

     

     

    .\AnaplanClient.bat -debug -service "https://api.anaplan.com" -auth "https://auth.anaplan.com" -user "<username>" -workspace "7g1cb09d652b041801654aa9b" -model "E4BDDAA4F28464179EFDAA345" -L -get:csv output.csv

     

    EDIT

     

    To further expand on my previous answer, it is also possible to export the contents of a particular list into a csv file. See below for the command structure.

     

    .\AnaplanClient.bat -debug -service "https://api.anaplan.com" -auth "https://auth.anaplan.com" -user "<username>" -workspace "7g1cb09d652b041801654aa9b" -model "E4BDDAA4F28464179EFDAA345" -execute -l "1000015" -get:csv output.csv

     

    @anildudam To respond directly to your initial post, your issue is with the -execute flag. For metadata commands (like -L), you cannot include the -execute flag, but for data commands (like -l), it is required. The above examples should fully answer your question.

     

  • anildudam
    edited November 2022

    Hi @ManjunathKN ,  @StevenBeerthuizen and @ryan_kohn 

    Thank you so much for your quick responses and possible solutions.

    Really very appreciate your help and support.

     

    Thank you and regards,

    Anil