Here is my code sample, though i set the method as post it will set Request
Method to OPTIONS and request payload won't be set.
there is no problem with CORS since it is working with chorme plugging such
as Postman and Rest Console. i have checked both tools requested to server
is request method:post, Content-Type:applicaion/json and data in
$scope.data will be set to request payload. what would be the reason?
angular.module('httpExample', []).controller('FetchController', ['$scope',
'$http', '$templateCache',
function($scope, $http, $templateCache) {
$scope.headers= {
'Accept': '*/*',
'Content-Type': 'application/json; charset=UTF-8'
};
$scope.method = 'POST';
$scope.url = 'http://localhost:56652/reqresp.svc/json/post';
$scope.data={"requests":[{"__type":"AuthenticateAndGetProsties:#LabOra.ProsteModul.ReqResp.Requests",
"Authentication":{
"__type":"UserAuthentication:#LabOra.ProsteModul.ReqResp","Username":"xxx","Password":"yyyy"
}}]};
$scope.fetch = function() {
$scope.code = null;
$scope.response = null;
$http({method: $scope.method, url: $scope.url,data:
JSON.stringify($scope.data),headers:$scope.headers, cache: $templateCache}).
success(function(data,status) {
$scope.status = status;
//$scope.data =x2js.xml_str2json(data);
$scope.data =data;
}).
error(function( status) {
$scope.data = "Request failed";
$scope.status = status;
});
};
}]);
})(window.angular);
Here is my code sample, though i set the method as post it will set Request
Method to OPTIONS and request payload won't be set.
there is no problem with CORS since it is working with chorme plugging such
as Postman and Rest Console. i have checked both tools requested to server
is request method:post, Content-Type:applicaion/json and data in
$scope.data will be set to request payload. what would be the reason?
angular.module('httpExample', []).controller('FetchController', ['$scope',
'$http', '$templateCache',
function($scope, $http, $templateCache) {
$scope.headers= {
'Accept': '*/*',
'Content-Type': 'application/json; charset=UTF-8'
};
$scope.method = 'POST';
$scope.url = 'http://localhost:56652/reqresp.svc/json/post';
$scope.data={"requests":[{"__type":"AuthenticateAndGetProsties:#LabOra.ProsteModul.ReqResp.Requests",
"Authentication":{
"__type":"UserAuthentication:#LabOra.ProsteModul.ReqResp","Username":"xxx","Password":"yyyy"
}}]};
$scope.fetch = function() {
$scope.code = null;
$scope.response = null;
$http({method: $scope.method, url: $scope.url,data:
JSON.stringify($scope.data),headers:$scope.headers, cache: $templateCache}).
success(function(data,status) {
$scope.status = status;
//$scope.data =x2js.xml_str2json(data);
$scope.data =data;
}).
error(function( status) {
$scope.data = "Request failed";
$scope.status = status;
});
};
}]);
})(window.angular);
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.