akshunds | 2020-10-16 04:28:51 UTC | #1
Hi. I have a problem updating addresses on a user. Updating other fields than Addresses I have no problems with. I use C#. This is my Contact that I put in a list and add as an attribute to the UpdateUser class:
Contact contact = new Contact(); contact.Address = "41347834"; contact.MediaType = Contact.MediaTypeEnum.Phone; contact.Type = Contact.TypeEnum.Primary;
I have tried:
Contact contact = new Contact(); contact.Address = "41347834"; contact.MediaType = "PHONE"; contact.Type = "PRIMARY";
But its not allowed as MediaType and Type does not take string, but demands Contact.MediaTypeEnum and Contact.TypeEnum
akshunds | 2020-10-16 04:36:45 UTC | #2
I have remembered putting the right version in also btw
This is the error I get: PureCloudPlatform.Client.V2.Client.ApiException: 'Error calling PatchUser: {"message":"Input is invalid or malformed. Reason: Invalid address type: primary","code":"general.bad.request","status":400,"messageParams":{"errorCode":"GENERALBADREQUEST"},"contextId":"edc232dd-56d6-456d-a977-6191596b960f","details":[],"errors":[]}'
Jerome.Saint-Marc | 2020-10-16 08:18:59 UTC | #3
Hello,
I haven't tried via C# (no dev environment for this unfortunately) but I have checked using the REST API directly.
Some feedback:
When you perform your PatchUser, you must set the Version in the UpdateUser body (mandatory property). The Version number is the current version of the user. You can obtain it with a GetUser (before making the PatchUser request).
The phone numbers are modified via Addresses (List<Contact>) in the UpdateUser body. From what I have seen at the REST API level, the request will override the current addresses with the ones provided in the Update User/PatchUser request. So you would have to copy the list of current addresses, that you can obtain with a GetUser, modify/add/delete the necessary ones, and use this list for your PatchUser body (UpdateUser.Addresses). Otherwise, if you send only one Phone Contact, I believe this will reset your user's addresses to a single one - the phone contact.
As you are modifying Addresses, for the phones, you can use: contact.MediaType = Contact.MediaTypeEnum.Phone And for the type: contact.Type = Contact.TypeEnum.Work; -> WORK:Work, WORK2: Work2, MOBILE: Mobile, ... (Updating the number associated with Work, if it was set to Primary Voice, will cause the PrimaryContactInfo to be updated - Phone/Primary).
Regards,
system | 2020-11-16 08:23:52 UTC | #4
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 9094