Http request with basic auth

Hi, i need to do an http request to retreive json, but i have 401 error, because i don’t know how to pass properly the credentials. Any help please?? this is a VPN

$scope.chiamataUno = function() {
$http.get(‘ BSDL/queueelements/?cp=DCMSVS_CONN1’,{params:{“username”: “DEMVSINT_ADMIN”,“password”: “Password01”}})
.success(function(response) {
$scope.caseTaskId = response.caseTaskId;
$scope.stepName = response.stepName;
console.log($scope.stepName + " " + $scope.caseTaskId);
.error(function(response) {

this is the headers log

Request URL:
Request Method:GET
Status Code:401 Unauthorized
Request Headersview source
Accept:application/json, text/plain, /
User-Agent:Mozilla/5.0 (Linux; Android 4.4.2; ASUS_T00J Build/KVT49L) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/ Mobile Safari/537.36
Query String Parametersview sourceview URL encoded
Response Headersview source
Content-Type:text/html; charset=UTF-8
Date:Wed, 09 Dec 2015 11:02:14 GMT
WWW-Authenticate:Basic realm="WebLogic Server"
X-Powered-By:Servlet/2.5 JSP/2.1

here is a detailed explanation…

but the the meat of it is here, you need to set the header with the Base64 encoded string

var authdata = Base64.encode(username + ':' + password);
$http.defaults.headers.common['Authorization'] = 'Basic ' + authdata;

thank you boss…i’ll try…

nothing…doesn’t work!!!

GET…nsabileBSDL/workbaskets/Responsabile20%BSDL/queueelements/?cp=DCMSVS_CONN1 ionic.bundle.js:19341
(anonymous function) ionic.bundle.js:19341
sendReq ionic.bundle.js:19160
$http.serverRequest ionic.bundle.js:18872
processQueue ionic.bundle.js:23394
(anonymous function) ionic.bundle.js:23410
Scope.$eval ionic.bundle.js:24673
Scope.$digest ionic.bundle.js:24484
Scope.$apply ionic.bundle.js:24778
(anonymous function) ionic.bundle.js:57513
eventHandler ionic.bundle.js:12098
triggerMouseEvent ionic.bundle.js:2865
tapClick ionic.bundle.js:2854

no no no it’s my fault now work…but how can i take the json?

Check $http manual first, in looks like u have mistake in request object for $http, also u should know how ur backend works(get, post, put and etc) and choose right one, for example for post it will lool like:
var req = { method: 'post', url: '', data: [username:'TestUser', password: 'testuserspassword'], }; $http(req).then(function(response){ /*success callback*/ }, function(response){ /* error callback*/ });

i can use this way with get metho?

sure something like this:
var url=''; var req = { method: 'get', url: url } $http(req).then(function(response) { console.log(; });

or u can use shortcat:


many thanks the problem was in the url…anyway your methods can be helpful

and for this post any solutions ?? thanks in advance

Mb i dont get the idia but first of all dont use success,error functions, use then nad there the variabale is response object that will be parsed data field where u will have data form request, i dont need to stringify it, if u whant just look through it u can write something like:
.then(function(response){ var data =; for(var i in data) { console.log(data[i]): } });

thank you…i’ll try, I post a screen shot, maybe can be useful

U have array of objects in your response?

yes…24 objects…and in every object other object

And what u whant to do with them?

i need to show in a list and put in a database…

So for lits i think you should use ng-repeat over ur data, for writing the database its the same like reading from backend, you just need to know what requests u need to perfom and what data its requered.