infusionsoft-api
infusionsoft-api copied to clipboard
Update Custom field
Hey, You can create and update Custom field, however, there are no methods to update contact. Is there any way to update contact's custom field. Thank you
I am not a developer on this project, but when I do this I add the custom field to the object being saved in the contact. For example:
const contact = {
FirstName: 'Victoria',
LastName: 'French',
Email: '[email protected]',
_myCustomField: 'They always start with an underscore',
};
ContactService.add(contact).then(...);
For anyone who happens onto this issue (Like I Did) but is attempting to manually hit the InfusionSoft REST API to add or query for Custom Fields (ie without this library):
- Custom Fields are supplied as an array property when you do an Insert / Upsert that takes ONLY the Custom Field Id and supplies the value you want to assign to that custom field as a part of the "content" property.
- In order to get the Custom Field Id you need to use the following REST Api endpoint which will return all of your Custom Fields and their Id which you need to supply to assign a value: https://developer.infusionsoft.com/docs/rest/#!/Contact/listCustomFieldsUsingGET
- Once you have the list of Custom Fields and their Id, find the Id for the field you want to update (lets say it's 36)
- Now you can format your JSON to pass to Create or Update. It should look something like this:
{
"duplicate_option": "Email",
"email_addresses": [
{
"email": "[email protected]",
"field": "EMAIL1"
}
],
"phone_numbers": [
{
"extension": "",
"field": "PHONE1",
"number": "6666666666",
"type": "Work"
}
],
"custom_fields": [
{
"id": 36,
"content": "126lbs"
},
{
"id": 37,
"content": "5 feet 9 inches"
}
]
}
- The custom_fields array object never references the field's name (In this case that would be Weight). EVERY entry in this array must have both an id property and a content property in order to be valid (see the similarities between 36 and 37). You will specify the id and the value (which is held in the content property) for each.
- Submit the above JSON to the following REST Api endpoint and you will Update OR Create the contact for the above user: https://developer.infusionsoft.com/docs/rest/#!/Contact/createOrUpdateContactUsingPUT
Notes: If you have any problems you should add the custom fields manually from the InfusionSoft admin area and then use the following REST API endpoint to pull down the contact you just added the custom property to: https://developer.infusionsoft.com/docs/rest/#!/Contact/loadUsingGET This will allow you to better visualize how the Create / Upsert API's expect to receive the data.
DONT FORGET: You need to supply the optional_properties Parameter to TELL the above GET endpoint to return custom_fields. Othewise the Contact instance that is returned will leave off the custom_fields which is probably all you are having trouble with anyway.