jbostoen / itop-jb-powershell

PowerShell module to interact with iTop API
https://jeffreybostoen.be
7 stars 4 forks source link

Create computer with new document attached? #3

Closed sanepidziak closed 2 years ago

sanepidziak commented 2 years ago

When creating a new computer with a new document, should I:

  1. Pass document parameters in the hashtable of "-Fields" attribute of New-iTopObject command? Like this:
    $parametrs_PC = @{
    'name' = $ComputerName
    'org_id' = 3 
    'location_id' = 1 
    'brand_id' = 29 
    'model_id' = 330 
    'osfamily_id' = 4 
    'osversion_id' = 328 
    'type' = 'laptop'
    'cpu' = 'Intel Core i5-11300H'
    'ram' = '8GB'
    'serialnumber' = 'numerseryjny'
    'asset_number' = 'AB-xxx'
    'move2production' = '2021-12-14'
    'purchase_date' = '2021-11-18'
    'end_of_warranty' = '2024-11-18'
    'contacts_list' = @(@{'contact_id'=344})
    **'documents_list' = @(@{'name'=$ComputerName })**
    }
  2. Create a document first and THEN attach it to a computer?

The first method returns an error:

iTop API returned an error: 100 - Error: documents_list: name: Unknown attribute
jbostoen commented 2 years ago
  1. This is an iTop REST API question again. Please refer to the documentation there for proper structure. I'd always suggest referring to IDs. In this case the attribute field's name is likely document_id

  2. AFAIK you have to create the document first, since the list actually contains a link to the existing document.