angularjs - $http.post send Authorization Header -
i attempting pass authorization header $http.post call .net web api service.
if use :
$http.post(urls.getemployeeinfo, { withcredentials: true, headers:{ 'authorization': 'basic ' + btoa(username + ":" + password)} } ); the authorization header not sent service.
the following works :
$http({ url: urls.getemployeeinfo, method: "post", withcredentials: true, headers: { 'authorization': 'basic ' + btoa(username + ":" + password) } }); why doesn't $http.post send authorization header ?
thanks
$http takes 1 argument: config [documentation]
$http.post takes 3 arguments: url, data, (and optional) config [documentation]
so if want pass configuration options, such headers, need send them third argument, rather second:
$http.post(urls.getemployeeinfo, postdata, { withcredentials: true, headers:{ 'authorization': 'basic ' + btoa(username + ":" + password)} } );
Comments
Post a Comment