We have our External Contacts associated with an Organisation. I am updating the External Contact using the API using the body like the one below. The users' details update correctly. However, the Users Organisation attribute is then removed, and the user is no longer associated with the organisation.
{
id = ContactId,
firstName = SPFirstname,
lastName = SPLastname,
title = SPJobTitle,
workEmail = SPEmail,
workPhone = new
{
display = SPMobile
},
schema = new
{
id = "id goes here",
version = version goes her
},
customFields = new
{
line_manager_text = LineManager,
line_manager_phone_text = LineManagerPhone,
service_area_text = ServiceArea
}
};
Anyone know why this Organisation attribute is removed. I would have thought that as I am not referencing it in the body the Organisation attribute will remain what it was previously.
Assuming you are using PUT /api/v2/externalcontacts/contacts/{contactId} for this.
PUT is an operation that triggers a full update of the object.
I mean the content provided in the PUT Request Body will replace the existing content with what you send.
That's why you need to provide the externalOrganization attribute.
As a matter of fact, with PUT, you should do a GET first - then modify the content you got from GET adding/removing/changing what you want - and using this as the body for the PUT.
PATCH is an operation that triggers a partial update - only attributes you have provided in the request.
There is no PATCH method supported on external contact.
My answer on PUT and PATCH above was to explain the expected behaviour for each of these HTTP methods in general: replace full object, or update object.
It does not mean a PUT and a PATCH method are always both available on a specific type of objects.
With External Contacts, it is only PUT.