Create a computer with a contact?
sanepidziak opened this issue · 6 comments
Is it possible to create a computer with a contact person? This is my fields parameter:
$parametry_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' = 'AS-xxx'
'move2production' = '2021-12-14'
'purchase_date' = '2021-11-18'
'end_of_warranty' = '2024-11-18'
'contacts_list' = @{'contact_id'=344
'contact_name' = 'Doe'
}
}
Everything works except the contacts_list parameter. I get the following error:
iTop API returned an error: 100 - Error: contacts_list: A link set must be defined by an array of objects
Hi
I think something went wrong in the formatting?
Anyhow, I'm not sure if it would work or if I actually need to modify something; but I noticed you are specifying a single object for contacts_list instead of an array with one object in it.
Glad to see more people are using this module :)
$parametry_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' = 'AS-xxx'
'move2production' = '2021-12-14'
'purchase_date' = '2021-11-18'
'end_of_warranty' = '2024-11-18'
'contacts_list' = @(@{'contact_id'=344
'contact_name' = 'Doe'
})
}
When I change it to be an array with one object, the error message changes. It seems like it's trying to edit an existing contact? I only want to link an existing contact to a new PC.
Can you provide the error please?
Also you might want to check iTop's API: https://www.itophub.io/wiki/page?id=latest%3Aadvancedtopics%3Arest_json#operationcore_create
If it's an existing contact, you should be able to use just the ID of the contact and leave contact_name out of it.
Here's the error message:
iTop API returned an error: 100 - Error: contacts_list: contact_name: Attempting to set the value on the read-only attribute lnkContactToFunctionalCI::contact_name
That's actually an iTop API error. Does it work if you leave that part out and just use contact_id like you did?
If it's an existing contact, you should be able to use just the ID of the contact and leave contact_name out of it.
Okay, that worked! It added the new computer with contact linked.