Basic Authentication fails but in postman it works. [Rest API v2]

I am getting below error while making API call via code(node js).
“You are not authenticated. Authentication required to perform this operation.”, but it postman I am getting a successful response.

Attached error logs below,

Hi @SamuraiKrish

Postman is doing quite a few things behind the scenes which your code may not be. As a start, check

  1. You’re using the same e-mail address and API token (obvious but worth checking)

  2. You’re 64 bit encoding the details in 1 above

  3. You’re passing the authentication in as Basic

It may be useful to show here the section of code where you actually call the API (anonymise e-mail and token, but have them so they’re obvious), so we can check your code