I am doing inline validation for emailId and checking whether emailid already exists or not in database but I am getting this error 406 (Not Acceptable).
For almost every email testcase it is working fine only for one case it is getting failed and i am getting this error in developer tool
GET https://localhost:9002/provisioning-console/json/user/get/user/email-id/fff@dd.cc?ts=1480929984199 406 (Not Acceptable)
user-add-panel.html
<div>
<div class="col-xs-8 col-sm-8 col-md-9 col-lg-9 controls">
<input type="text" class="input-xlarge" id="emailId" name="emailId" autofocus="autofocus" ng-model="addUser.email" ng-model-options="{allowInvalid: true}" ng-change="invokeChangeEventEmailId()" ng-blur="invokeOnBlurEventEmail(addUser.email)" ng-pattern="emailpattern"
placeholder="{{::'placeholder.addUser.emailId'|translate}}" required="true" ng-maxlength="254" />
</div>
user-add-panel.js
$scope.invokeOnBlurEventEmail = function(email) {
if (email == null) {
$scope.emailvalidating = false;
} else {
$scope.emailvalidating = true;
}
var getRolePromise = userDetails.getUserByEmail(email);
getRolePromise.then(function(response) {
$scope.addUserForm.emailId.$setValidity('unique', false);
$scope.emailvalidating = false;
}, function(error) {
$scope.addUserForm.emailId.$setValidity('unique', true);
if (error.errorCode === 'error.invalid.email') {
$scope.emailvalidating = false;
} else {
toasty.serviceError(error);
$scope.emailvalidating = false;
}
});
}
This is my service which is calling the API
user-state.js
getUserByEmail: function(emailId) {
var defer = $q.defer();
restClientTemplate.execute({
method: 'GET',
url: 'json/user/get/user/email-id/' + emailId,
}).then(function(response) {
defer.resolve(response.results);
}, function(response) {
defer.reject(response);
});
return defer.promise;
}