Trouble connecting to API

I am trying to connect to the API for the first time with NodeJS, but I keep getting the error: “connect ECONNREFUSED”. In the options “headers” parameter, for the username:password I have my actual username and password. I also tried it with headers: ("Authorization", "Basic " + btoa("username:password")); but that threw an error "btoa is not defined”.

Thoughts on what I’m doing wrong?

Here’s my javascript code:

const https = require('https');

const options = {
              baseURL: '', 
              method: 'GET',
              headers: ("Authorization", "Basic username:password")
console.log('options: ' + JSON.stringify(options));
const myResult = httpGet(options); //, res => { 

The output of my console.log is:

{“method”: “POST”, “baseURL”: “”, “headers”: “Basic username:password”}

We’re no NodeJS experts, but the “btoa is not defined” seems to be an NodeJS specific issue that we would try to solve first. Here is an topic on StackOverflow with some suggestions:

Yes, I looked at that post yesterday prior to submitting my post, and as suggested I also tried using the command var ulog = Buffer.from('username:password').toString('base64'); but with my actual username:password and was unsucessful. Here’s the code:

var ulog = Buffer.from('username:password').toString('base64');

const options = {
              //url: '', //Enter your base api url from RouteXL
              url: '',
              method: 'GET',
              headers: ("Authorization", "Basic " + ulog)
const myResult = await httpGet('', options); //, res => {

Here’s what I’m sending:
options: {“url”:“",“method”:“GET”,“headers”:"Basic username:password”}

I’m not getting a JSON back. Am I missing something else?

There is no error on our log for your account, so it seems to return a valid result. When was the last request you’ve sent? What are you getting back exactly? Can you share the result?

I’ve tried it multiple times within the last two hours and again just moments ago.

 console.log("    sent: " + JSON.stringify(options));
 console.log("received: " + JSON.stringify(myResult));

Here’s what I get back on output (but with encoded username:password):

sent: {"url":"","method":"GET","headers":"Basic myEncodedUsername:Password"}
received: ""

We’ve digged a little deeper in the lower level server logs and found 401 errors. Your httpGet function should give that HTTP code too. That means the connection worked but authentication failed. So you’ll need to double check that part.