I am trying to create a list item using angularjs Http service, but am getting an error 403 Forbidden. PFB the code:
<script src="http://win-pmmmma92p9v:19522/sites/JobSeekers/Resources/angular.js"></script>
<script src="http://win-pmmmma92p9v:19522/sites/JobSeekers/Resources/jquery-3.2.1.js"></script>
<script>
var myApp=angular.module("myApp",[]).controller("myController",function($scope,$http)
{
$scope.addQuestion = function(){
return $http({
headers:{"Accept":"application/json;odata=verbose","X-RequestDigest":$("#_REQUESTDIGEST").val(),"content-type":"application/json:odata=verbose"},
method:"POST",
url:_spPageContextInfo.webAbsoluteUrl+"/_api/web/lists/getByTitle('Questions')/items",
data:{
'Title' : $scope.Title,
'Description':$scope.Description,
'Tag':$scope.Tag
}
}).then(saveContact)
.catch(function(message)
{
console.log("addQuestion() error:"+message);
});
function saveContact(data,status,headers,config)
{
alert("Item added successfully");
return data.data.d;
}
}
});
</script>
<body>
<div ng-app="myApp">
<div ng-controller="myController">
Title<br>
<input type="text" ng-module="Title" id="title"><br><br>
Description<br>
<textarea ng-module="Description" id="description"></textarea><br><br>
Tag<br>
<input type="text" ng-module="Tag" id="tag"><br><br>
<button ng-click="addQuestion()">Post Your Question</button>
</div>
</div>
</body>
I have been trying it for two days, but still dint find any solution, can someone help?