Skip to main content
Question

Input file for btapi tool

  • October 15, 2024
  • 6 replies
  • 354 views

Fabien Landais
Forum|alt.badge.img+13

Hi,

 

Iโ€™m alooking for some example around the btapi.exe usage. Command lines are pretty understandable and usable with options and arguments but I donโ€™t know the file format for inputs. Apparently we can use json format or key=value format but I have never been succeeded to provide inputs to command as โ€œadd userโ€.

If somebody can provide me a json file example to create local users through btapi it will be wonderful :)

Did this topic help you find an answer to your question?

Fabien Landais
Forum|alt.badge.img+13

Just to add more information : 

The following command is working fine : .\btapi.exe --verbose --env-file .\env-file.txt --input-json --input .\vaultGroups.json add vault/account-group

 

with the following json file : 

{
  "name": "VaultGroup",
  "description": "This is my test Vault Group"
}

 

However if I want to add several VaultGroup in one shot it is not working anymore with the following syntax : 

[
{
  "name": "VaultGroup1",
  "description": "This is my test Vault Group 1"
},
{
  "name": "VaultGroup2",
  "description": "This is my test Vault Group 2"
},
{
  "name": "VaultGroup3",
  "description": "This is my test Vault Group 3"
}
]

 

I have this output in verbose : 

Config loaded (from environment), using BT_API_HOST=[], version=[v1]                                                                                        Parsing path [.\env-file.txt]                                                                                                                    Loading env from [C:\Users\W10LAB\Desktop\Unicancer\btapi\env-file.txt]                                                               
           Config loaded (from file), using BT_API_HOST=[access.unicancer.fr], version=[v1]                                                      
           Loading input file .\vaultGroups.json                                                                                                 
           Parsing path [.\vaultGroups.json]                                                                                                     
           add vault/account-group                                                                                                                          Read input data                                                                                                                       
           [                                                                                                                                     
           {
             "name": "VaultGroup1",
             "description": "This is my test Vault Group 1"
           },
           {
             "name": "VaultGroup2",
             "description": "This is my test Vault Group 2"
           },
           {
             "name": "VaultGroup3",
             "description": "This is my test Vault Group 3"
           }
           ]

           [                                                                                                                                                    {'name': 'VaultGroup1', 'description': 'This is my test Vault Group 1'},
               {'name': 'VaultGroup2', 'description': 'This is my test Vault Group 2'},
               {'name': 'VaultGroup3', 'description': 'This is my test Vault Group 3'}
           ]
Unexpected input parameters: 0, 1, 2


Forum|alt.badge.img+1
  • BeyondTrust Employee
  • October 15, 2024

Hello Fabien Landais,

Just looking through your API string, and some other API documentation, it could be possible the API only supports adding a single entry at a time, and you would need to use a do...while or forโ€ฆ program loop through the JSON file one entry at a time, running the BTAPI Command to add once per new Vault Group you wish to create.

This also seems to be the case as per your exmaple where a json with a single new entry works as expected. The JSON can contain many ther properties then just the name and descrption, hence the use of that format, I suspect.


Fabien Landais
Forum|alt.badge.img+13

Hi PhilC,

 

Thank you for your answer even if itโ€™s not the exact one I would like to hear ๐Ÿ˜…

Normally this kind of feature is really valuable to do mass import so if itโ€™s not usable like that itโ€™s a shame 


Forum|alt.badge.img+1
  • BeyondTrust Employee
  • October 16, 2024

Hello Fabien Landais - you absloutely can use the API for Mass Imports, you just have to loop through a list within your code, from what I can see.


Forum|alt.badge.img+1
  • Rising Star
  • February 13, 2025

I would also like to know if we can get a sample provisioned for using BTAPI for bulk imports


Forum|alt.badge.img+1

 

how to call and add jump groups using btapi, I am trying to add using 

 


D:\Cleanup\btapi>btapi add jump-group jumpgroup.json
Usage: btapi add [OPTIONS] RESOURCE
Try 'btapi add --help' for help.
โ•ญโ”€ Error โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Got unexpected extra argument (jumpgroup.json)    

 

 

Please help how to add multiple jump groups and group policies using btapi for mass import

 


Reply


Cookies

By clicking โ€œAccept Cookiesโ€, you agree to the storing of cookies on your device to enhance and personalize your experience. Learn more about our cookies.

 
Cookie settings