Hi - I’m trying to create projects via API - it seems that I cannot use custom fields in the payload like with all the other items (person, organization, deal/lead). Will this be implemented in the future?
I just get the error “Unknown field(custom_fields)” when providing custom field data.
Thomas
Sorry - my fault - I was running against API v1 not v2. Custom fields successfully transfered with api v2.
Hey Thomas! Can You help me understaning how are you handling the customfields..
My Issue:
→ I’m using the PersonAPI (v1) to createContact and whenever there is a custom pipedrive field (person) then it works perfect
→ But when some of our users mistakenly or unknowing add the custom fields (deals, organization etc) then createContactAPI fails ==> *Invalid field(s) in the payload: d342e6808b38dc59c8113ac7b6128062f9602dd5’
→ Without custom fields it is working perfect
async createContacts(contactsToCreate: ContactCreateInput[], event: CalendarEvent): Promise<Contact[]> {
const apiInstance = new PersonsApi(await this.getConfig());
const bookingQuestions = await prisma.eventType.findUnique({
where: { id: event.eventTypeId },
select: { bookingFields: true },
});
const mappedData = Object.fromEntries(
bookingQuestions.bookingFields
.filter((field) => field.type === "pipedrive_custom_field") // Only pipedrive fields
.map((field) => [field.apiKey, event?.userFieldsResponses[field.name]?.value ?? null]) // Match name with event values
.filter(([_, value]) => value !== null) // Remove null values
);
console.log(mappedData);
const result = contactsToCreate.map(async (attendee, index) => {
try {
const response = await apiInstance.addPerson({
AddPersonRequest: {
name: !!attendee.name ? attendee.name : attendee.email,
email: [{ value: attendee.email }],
phone: index === 0 ? event?.userFieldsResponses["attendee-phone"]?.value : "",
...mappedData,
},
});
console.log("success response", response);
if (!response.success) {
throw new Error(`Reponse unsucessful: ${response}`);
}
const result = response.data;
return result;
} catch (error) {
console.error("Error creating contact", { attendee, error });
throw error;
}
});
<---REST CODE --->
}