i am correctly getting the dealFields from the api and i have obtained the correct key for the dealFields
const { data: dealFieldsResult, error: dealFieldsError } = await tryCatch(
dealFieldsApi.getDealFields({
start: 0,
limit: 100,
}),
);
const costField = dealFieldsResult.data?.find(
(field: GetField) => field.name === "Cost",
);
console.log("costField", costField);
everything is okay so far, but then when i call the updateDeal
const { data: updatedDeal, error: updateError } = await tryCatch(
dealsApi.updateDeal({
id: deal.id,
UpdateDealRequest: {
[costField.key]: fields.cost,
[gpField.key]: fields.gp,
[eventDateField.key]: fields.event_date,
[leadInDateField.key]: fields.lead_in_date,
[eventTypeField.key]: fields.event_type,
[attendeesField.key]: fields.attendees,
},
}),
);
i would just get the following error
{
success: false,
error: "Validation failed: 3b71d5b6cea10e23f3f433d248add2020d4aff2e: Parameter '3b71d5b6cea10e23f3f433d248add2020d4aff2e' is not allowed for this request; 312f85de0ced3e87d5102af8799f88638fb0924a: Parameter '312f85de0ced3e87d5102af8799f88638fb0924a' is not allowed for this request; ebe2933b7b968117db0d0ca12a6b89eea6968e73: Parameter 'ebe2933b7b968117db0d0ca12a6b89eea6968e73' is not allowed for this request; 8daa51d82bd0cd1501a0c32bdad63e3dcb4a6524: Parameter '8daa51d82bd0cd1501a0c32bdad63e3dcb4a6524' is not allowed for this request; c8fea8cc9b03d66877452525f3f91fad865a4670: Parameter 'c8fea8cc9b03d66877452525f3f91fad865a4670' is not allowed for this request; 9f92052e82918d9c334777fa39060a8140782a54: Parameter '9f92052e82918d9c334777fa39060a8140782a54' is not allowed for this request",
code: "ERR_SCHEMA_VALIDATION_FAILED",
}
DealFieldsApi is from v1 and DealsApi is from v2 since v2 doesn’t have DealFieldsApi yet.
import { Configuration, DealsApi } from "pipedrive/v2";
import { DealFieldsApi, type GetField } from "pipedrive/v1";