You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import Pipedrive from 'pipedrive';
let apiClient = new Pipedrive.ApiClient();
// Configure API key authorization: api_key
let api_key = apiClient.authentications['api_key'];
api_key.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//api_key.apiKeyPrefix = 'Token';
// Configure OAuth2 access token for authorization: oauth2
let oauth2 = apiClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';
let apiInstance = new Pipedrive.PersonsApi(apiClient);
let opts = Pipedrive.NewPerson.constructFromObject({
// Properties that you want to update
});
apiInstance.addPerson(opts).then((data) => {
console.log('API called successfully. Returned data: ' + data);
}, (error) => {
console.error(error);
});
I was not able to add a new person to Pipedrive. I kept getting this error:
TypeError: data.map is not a function
at Function.convertToType (/var/task/node_modules/pipedrive/dist/ApiClient.js:1017:25)
at Function.constructFromObject (/var/task/node_modules/pipedrive/dist/model/BasicPerson.js:72:48)
at Function.constructFromObject (/var/task/node_modules/pipedrive/dist/model/NewPerson.js:73:33)
at createPipedrivePerson (/var/task/functions/updateCrmInfo.js:247:36)
After some tries and errors, I found a solution that worked for me. I believe the error lies in the Pipedrive.NewPerson.constructFromObject() method. Here is the code that worked for me:
import Pipedrive from 'pipedrive';
let apiClient = new Pipedrive.ApiClient();
// Configure API key authorization: api_key
let api_key = apiClient.authentications['api_key'];
api_key.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//api_key.apiKeyPrefix = 'Token';
// Configure OAuth2 access token for authorization: oauth2
let oauth2 = apiClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';
let apiInstance = new Pipedrive.PersonsApi(apiClient);
let opts = {
// Properties that you want to update
};
const response = await apiInstance.addPerson(opts);
The text was updated successfully, but these errors were encountered:
Thank you for reporting an issue, and I'm glad there is a solution that worked for you 👍
Unfortunately I can't reproduce the issue from my side, but maybe you could provide us more details.
First of all it would be good to know what fields you're sending to API and version of SDK that you have.
this is crazy i was about to report exactly the same thing. @bashmach at least make a PR to update the docs please, it's been 2 months the issue is opened, the least you could do is correct the docs.
EDIT: the code provided doesn't work because the fields passed are snake cased (org_id but the docs mention camelcased fields orgId)
Given the provided code:
I was not able to add a new person to Pipedrive. I kept getting this error:
After some tries and errors, I found a solution that worked for me. I believe the error lies in the
Pipedrive.NewPerson.constructFromObject()
method. Here is the code that worked for me:The text was updated successfully, but these errors were encountered: