KelvinTegelaar / AutotaskAPI

Autotask 2020.2 REST API PowerShell wrapper
https://cyberdrain.com
MIT License
67 stars 25 forks source link

[BUG] Cannot add a member with the name "id" because a member with that name already exists. #47

Closed MadRainbow closed 2 years ago

MadRainbow commented 2 years ago

I am running the following,

$Data=Get-AutotaskAPIResource -Resource Companies -SearchQuery '{"filter":[{"op":"eq","field":"Educational: Establishment Type","udf":true,"value":"Multi-academy trust"}]}'

$Data | ForEach-Object {$_.CompanyCategoryID = "101"}

$Data | Set-AutotaskAPIResource -resource Companies

This worked perfectly until recently, changing the Autotask Company Category field, however in the last couple of weeks (ish) I am getting an error....

Add-Member : Cannot add a member with the name "id" because a member with that name already exists. To overwrite the member anyway, add the Force parameter to your command.

Trying to add -force to the end of the Set-AutotaskAPIResource throws up an error that the Force parameter isn't found.

Has something changed recently that could be causing this?

Thanks

David

KelvinTegelaar commented 2 years ago

Nothing changed, but previously you probably did $data | foreach-object { } instead of data | set-autotaskapiresource, or you only had one object returned and now you have multiple.

I dont think I made support for accepting arrays over the pipeline :)

MadRainbow commented 2 years ago

Hi Kelvin,

Its always had multiple entries (around 500).

Are you saying I need to loop the set command and do one record at a time?

Thanks

D

KelvinTegelaar commented 2 years ago

Yes. See the readme for examples :)