Pipedrive.Client is not a constructor

I am using pipedrive in AWS Lambda NodeJS with this piece of code.

var Pipedrive = require('pipedrive');
var pipedrive = new Pipedrive.Client(MY_API_KEY, { strictMode: true });

It says
Pipedrive.Client is not a constructor

Please help.

Hello @Ashas_Ahmad

It seems like you’re using the “old way” (before the latest release) way of using Pipedrive NodeJS SDK.

If you’re using the latest version, could you try this?

I have tried with pipedrive-client as well. The error is same.

Hi @Ashas_Ahmad

Here is an example with Node.js (14) and client-nodejs (^11.0.0)

index.js

const lib = require('pipedrive');

lib.Configuration.apiToken = '<Your API TOKEN>';

async function test() {
    try {
        const user = await lib.UsersController.getCurrentUserData();

        console.log('user', user);
    } catch (err) {
        console.log('error', err);
    }
}

test()

package.json

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {},
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "pipedrive": "^11.0.0"
  }
}

Could you try this example and see if it works for you? And if it doesn’t, could you provide an example that does not work for you (index.js and package.json)?

Hi,

Thanks for previous feedback. It worked.
Now I am stuck somewhere where I have to update the custom field ID of a particular Deal.

I have that KEY for the custom field and I also have the ID.

Now I am just updating the deal but it says

“Date and time fields related to activities cannot be updated.”

Exact Error in NodeJS:
{“level”:50,“time”:1624866111546,“msg”:“Vandium Handle - Exception”,“pid”:17147,“hostname”:“MACs-MacBook-Pro.local”,“errorMessage”:“HTTP Response Not OK”,“errorCode”:400,“errorResponse”:"{“success”:false,“error”:“Date and time fields related to activities cannot be updated.”,“error_info”:“Please check developers.pipedrive.com for more information about Pipedrive API.”,“data”:null,“additional_data”:null}",“v”:1}

The code is

   let dealPd = await lib.DealsController.getDetailsOfADeal(body.dealId, () => {})
    dealPd.data[INTEREST_LEVEL_KEY_DEAL] = body.interestLevel;
    await lib.DealsController.updateADeal(dealPd.data);

Although INTEREST_LEVEL_KEY_DEAL = ‘223b11c172d10692d70cf07701bc2fb08dbb1c7b’ in my case and InterestLevel id is 195.

Please help me out. I have seen the other thread on this on this platform but no one faced this issue.

Hi @Ashas_Ahmad

The update deal method does not accept all the fields from GET /deal response, more about updateADeal.

I think this version should cover your case (if body.interestLevel value is valid for INTEREST_LEVEL_KEY_DEAL custom field)

await lib.DealsController.updateADeal({
   id: body.dealId,
   [INTEREST_LEVEL_KEY_DEAL]: body.interestLevel
});