Hi, i have a problem when i want to add an id in my post request. I use node.js. So this is my code.
async function addPersonInOnePipeDriveOrganization(capsule) {
logger.debug('addPersonInOnePipeDriveOrganization function');
// Find the id of the user's organization.
const id = await getOrganizationIDByName(capsule);
const user_id = await getPersonIDByName(capsule);
const data = {
id, // Id of the organization
user_id, // Id of the user
};
return new Promise((resolve, reject) => pipedrive.Persons.add(data, (err, person) => {
if (err) return reject(err);
logger.debug(`Person added with success ${JSON.stringify(person)}`);
return resolve(person);
}));
}
And this is my function for get the organization id, this is the same function for get the person id.
async function getOrganizationIDByName(capsule) {
logger.debug('getOrganizationIDByName function');
const search = pipedrive.SearchResults.field({
term: get(capsule, 'sessionMemory.companyName'),
exact_match: true,
field_key: 'name',
field_type: 'organizationField',
return_item_ids: true,
}, (err, data) => {
if (err) throw err;
logger.warn(data);
});
const result = await requestPromise({
uri: search.url.href,
method: 'GET',
json: true,
});
logger.debug('--------- RESULT -> ORGANISATION ID ------------');
logger.debug(result.data[0].id);
return result.data[0].id;
}
This is the complet error:
Error: Pipedrive API error:Inserting ID with POST request is not allowed. If you have any questions, please contact Pipedrive support
I think it’s my bad but i don’t find the solution …
Thank you for your help.