christaylorcodes / ConnectWiseManageAPI

PowerShell wrapper for the ConnectWise Manage REST API
MIT License
108 stars 61 forks source link

Update (or add) contact email address for a contact. #51

Closed AHelsby closed 11 months ago

AHelsby commented 12 months ago

I'm using the following code to update the email address for a company contact - `$type=@{ "value"="bucket@company.com"; "domain"="@company.com"; "communicationType"="Email"; "defaultFlag"="true"; "type"=""; }

$jsontype=convertto-json $type

update-cwmcontact -id 33463 -operation replace -path communicationItems -value $jsontype`

which is the closest I've got, but get An exception has been thrown. --> Response status code does not indicate success: 400 (Bad Request). An error | has been thrown. --> --> { "code": "InvalidPatch", "message": "Could not cast or convert from System.String | to ConnectWise.Apis.v3_0.v2015_3.Company.Contact.ContactCommunicationItem[]." } at Invoke-CWMWebRequest,

Using 0.4.11.0

Any ideas on what I need to update here? I've removing type, default flag etc so i'm left with just the communicationType and value but still get the same error message

christaylorcodes commented 11 months ago

Use the New-CWMContactCommunication function.