Hi There,
I want to build a rest API that can be accepted Basic authorization to get the session id. I am unable to do so.
function (host, method, requestUrl, content) {
var restHost = this.getTransientRestHost(host);
requestUrl = restHost.url + requestUrl;
System.log("requestUrl "+requestUrl) ;
var data = (content != "") ? JSON.stringify(content) : null;
var request = restHost.createRequest(method, requestUrl, data);
request.contentType = "application/json";
var user = 'username';
var pwd = 'password';
var auth = user+':'+pwd;
request.setHeader('Authorization' ,'Basic '+auth); //: here I am setting up header like this.
var response = request.execute();
return response;
};
But, I am getting an error, am I missing something there? please help.
Laxmi
Hi,
Yes, you are missing the fact that the value after "Basic " (user + ':' + pwd) must be Base64-encoded.
There are some samples showing how to correctly configure basic authentication with HTTP-REST plug-in; see, for example, https://code.vmware.com/samples?id=2032#code
Hi,
Yes, you are missing the fact that the value after "Basic " (user + ':' + pwd) must be Base64-encoded.
There are some samples showing how to correctly configure basic authentication with HTTP-REST plug-in; see, for example, https://code.vmware.com/samples?id=2032#code