Http authentication

I tried to use the httpDo() with the following code for basic authentication but it is not working, can someone advise on this ?

I got a “Failed to load resource: the server responded with a status of 401 (Unauthorized)” from the server in the console."

apiMetrics = "http://somehost.com/api/v2/monitoring/metrics";

function setup() {
    createCanvas(400, 400)
    var url = apiMetrics;


    httpDo(
        url, {
            method: 'GET',
            headers: {
                authorization: 'Basic username:password'
            }
        },
        function (data) {
            console.log(data);
        }
    )
}

Is that a valid link? I couldn’t get it to work. If you post this link in your browser, do you get the same error? That would be my first test.

Kf

Yes, i removed the actual link…

If I goto the URL manually, I was prompted with username & password and after I login, I get this json data …

{
"code":0,
"result":[
{
"emq@127.0.0.1":{
"packets/pubrec/sent":7,
"packets/pubrec/missed":0,
"messages/sent":373843,
"packets/unsubscribe":0,
"packets/pubcomp/received":9,
"packets/suback":340,
"messages/qos2/sent":9,
"messages/received":430641,
"bytes/sent":18948545,
"packets/pingresp":16333,
"packets/connect":453,
"packets/sent":390992,
"messages/qos1/sent":0,
"packets/pubrel/missed":0,
"packets/puback/missed":0,
"bytes/received":22125284,
"messages/dropped":58515,
"packets/pubrel/received":7,
"packets/pubrec/received":9,
"messages/retained":3,
"messages/qos0/sent":373834,
"packets/pubrel/sent":9,
"packets/pubcomp/missed":0,
"packets/pubcomp/sent":7,
"packets/connack":453,
"packets/received":448000,
"packets/publish/sent":373843,
"packets/pingreq":16333,
"packets/publish/received":430641,
"packets/disconnect":208,
"messages/qos2/received":7,
"messages/qos1/received":0,
"packets/subscribe":340,
"packets/puback/sent":0,
"packets/puback/received":0,
"messages/qos2/dropped":0,
"messages/qos0/received":430634,
"packets/unsuback":0
}
}
]
}

Is this solved or are you still inquiring how to do it? Just dbl checking…

Kf

No, it is not resolved yet, I still cannot do authorization: 'Basic ’ method yet using httpDo …