Encryption Problem

Here is the below process I am following for encryption in Node.js, it is encrypting the data but when I am making the request to the ABDM API with that encrypted data it is showing sometimes 400 or an Invalid data enter error, can anyone suggest something how to process for it in node.js .
`
API - hitting this api after encryption https://healthidsbx.abdm.gov.in/api/v2/registration/mobile/login/verifyOtp

Encryption code .

async encryptData(plainText) {
try {
const publicKey = await this.generateAuthCert();
const publicKeyInstance = new NodeRSA();
publicKeyInstance.importKey(${publicKey}, ‘public’, ‘pkcs1’);
const encryptedValue = publicKeyInstance.encrypt(plainText, ‘base64’);
return encryptedValue;
} catch (error) {
console.log(error.message, error);
throw error;
}
}
`

Can anyone help me where I am doing wrong, although using pkcs1 padding also?