BitGo/BitGoJS

"items must be object, received item of type: string" at whitelisting an address

Antuan03 opened this issue · 2 comments

i get: "items must be object, received item of type: string",

at sending a createPolicyRule for example:

` const wallet = await bitgo
.coin(coin)
.wallets()
.get({ id: userWallet?.wallet_id });

  const policy = {
    action: {
      type: 'getApproval',
    },
    condition: {
      add: 'address',
    },
    id: 'withdraw_policy',
    type: 'advancedWhitelist',
  };

  const result = await wallet.createPolicyRule(policy);

  console.log(result);`

that code is exactly the same as the one in the docs here

also via API it gives me 401 and I have others calls with other endpoints and the same Authorization token works

I am getting the same error.

I figured out why my code wasn't working.

Here is the payload I am using now:

{
  id: crypto.randomUUID(),
  type: "advancedWhitelist",
  condition: {
    add: {
      item: whitelistAddress,
      type: "address",
    },
  },
  action: {
    type: "deny",
  },
}

The add condition needs to be an object with item property and type property.

Hope this helps!