Newbie: 401 on Hello world example

Hi folks
Just signed up and trying to get a basic handshake.

I’m constructing my request in Postman using the following

JS
var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic _myusername_:_mypassword_");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("https://api.routexl.com/status/Hello+world", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

and getting a 401 … does anyone have any thoughts on what I’m getting wrong here?

Many thanks

Curl
curl --location --request GET 'https://api.routexl.com/status/Hello+world' \
--header 'Authorization: Basic _myusername_:_mypassword_'

also get 401 if I use email instead of username

We did not test your example, but you probably should encode your username and password:

For example, if the browser uses Aladdin as the username and OpenSesame as the password, then the field’s value is the Base64 encoding of Aladdin:OpenSesame, or QWxhZGRpbjpPcGVuU2VzYW1l. Then the Authorization header will appear as:

Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l

1 Like

Ok cool that works thank you - sorry i missed the fact that you had to encode the username/password data :+1:

1 Like

Worked for me too, absolutly awesome, :raised_hands . I strangled for 3 days until I fell on this support