angularjs - $http.post resulting in OPTIONS 596 error or insufficient arguments -


i trying make $http.post call api endpoint (http://developer.zoopla.com/docs/read/arrange_appraisals) getting options error. tried pass url directly params ones in request, tried passing object second parameter. have created plunker here (http://plnkr.co/edit/0w1egx30decnwhc8odso?p=preview), please advise correct approach , causing error.

 angular.module('someapp',[])  .controller('somectrl',function($scope,$http){         $scope.data = {                         branchid : 49953,                         propertyid : 5646166,                         custname : 'joe',                         custemail : 'joe123@gmail.com',                         custnumber : '07978765543',                         custnumbertype : 'mobile',                         custtime : 'anytime',                         custmessage : 'some random message',                         custenquirytype : 'arrange_valuation',                         api_key :  'please in plunker attached'                         }    $scope.url = 'http://api.zoopla.co.uk/api/v1/arrange_appraisal.js'         $scope.postdata = function(){      alert('please check console error')      $http.post($scope.url,$scope.data)           .success(function(res){             console.log(res)           })           .error(function(err){             console.log(err)           })    }     $scope.postdata2 = function(){      alert('please check console error')      $http.post('http://api.zoopla.co.uk/api/v1/arrange_appraisal.json?branch_id=18269&property_id=5646170&name=somename&email=someemail@yahoo.com&phone=07476566718&phone_type=mobile&best_time_to_call=afternoon&message=hello&type_of_enquiry=looking_to_sell&api_key=pleasecheckplunker')           .success(function(res){             console.log(res)           })           .error(function(err){             console.log(err)           })    }  }) 

the payload not in correct syntax.

 $scope.data = {'branchid' : 49953,'propertyid' : 5646166,'custname' : 'joe', // , on.... }; 

also, add backslash @ end of url as:

$scope.url = 'http://api.zoopla.co.uk/api/v1/arrange_appraisal.js/'; 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -