I have googled and read for hours but have yet to find an example that works. I am invoking the Solcast API, which requires Basic auth and only a username containing an API key but no password.
The issue is I need to pass the username via msg.headers. When I include the username in the node properties dialog, the API call works fine, but I cannot seem to get it right passing it in msg.headers. The last code I tried, which didn't work, was this:
msg.headers = {};
APIkey = flow.get('APIkey');
var auth = 'Basic ' + new Buffer(APIkey).toString('base64');
//var auth = 'Basic ' + APIkey;
msg.ResourceID = flow.get('ResourceID');
msg.headers = {
"Authorization": auth
}
return msg;
Any help is greatly appreciated.
dave