Community
Showing results for 
Search instead for 
Do you mean 
Reply

Updating some fields on a contact the rest are st to null/default

New Member
Posts: 5
Country: Australia

Updating some fields on a contact the rest are st to null/default

Is it intended that when updating a contact any field not sent at all is set to null/default instead of retaining its current value?

 

 

Employee
Posts: 209
Country: USA

Re: Updating some fields on a contact the rest are st to null/default

It sounds like you are underposting.  In other words, you not passing all the fields that make up a contact.

 

A PUT operation should include *all* the contact fields that can be modified.   

 

E.g.  GET /contacts -> change field values -> PUT /contacts.

 

What you are trying to do is a partial update, also known as a PATCH operation.  This is not yet supported.

 

--Xavier

 

 

New Member
Posts: 5
Country: Australia

Re: Updating some fields on a contact the rest are st to null/default

So whats the recommended way to update only select fields?

 

I tried pulling down the contact record merging the fields i want to change and then sending the full contact record back but im getting an error about a custom field not allowed to be null even though thats was it was set as from the api.

It seems odd that this isn't supported. 

How do you recommend i achieve this without explicitly defining every field as this will then just break as soon as another custom field is added?

 

Thanks

Employee
Posts: 209
Country: USA

Re: Updating some fields on a contact the rest are st to null/default

The correct way to PUT a record is first to GET the record, modify only the fields that you need to change, then PUT the record.  This ensures that other fields will return their data.  You don't need to define every field up front, you simply need to know and modify the fields you care about on the model you received from a GET.

 

 

New Member
Posts: 5
Country: Australia

Re: Updating some fields on a contact the rest are st to null/default

Thats exactly what i tried to do but my client has a calculated custom field and it appears im not permitted to set it so i get this error when trying to save the merged full contact record:

 

Custom Field cust_yearsinoperation_012243550 does not accept null values\r\nParameter name: model

 

Wat am i suppose to do here? 

Employee
Posts: 209
Country: USA

Re: Updating some fields on a contact the rest are st to null/default

Ah, that's interesting.  Certainly you can't update a read-only field Smiley Happy  

 

If you omit that field from the model, does the PUT work?

New Member
Posts: 5
Country: Australia

Re: Updating some fields on a contact the rest are st to null/default

Yeah it does and thats whats im doing for now but i don't like that solution as in the future they may add another similar field and the integration will suddenly break. 

Is there an ETA for when PATCH will be supported?

Highlighted
Employee
Posts: 209
Country: USA

Re: Updating some fields on a contact the rest are st to null/default

One option you may be able to do now, is get /metadata for contacts, enumerate those fields so that so you can dynamically find read-only fields, and exclude them from a PUT.  

 

We could be more accepting of read-only fields on our end, and simply ignore them if you include them, which would be the easiest for you / others, and I tend to like that the best, but we need to make sure this doesn't have any other side effects to see if that's a good option.  

 

No ETA on PATCH but it is on the backlog.