I have a problem with posting data to the WP Rest API in combination with my Angular webApp. My first guess is that I am not posting the data in the right format.
My function to post the data is as follows: (some data is static for test purposes only)
$scope.submitComment = function () {
var d = new Date();
commentForm = [
{
'author_email': $scope.email,
'author_name': $scope.name,
'author_url': 'http://www.domain.com',
'content': $scope.comment,
'date': '2015-11-29T20:10:36',
'date_gmt': '2015-11-29T19:10:36',
'karma': '',
'parent': 0,
'post': $scope.postID,
'status': 'approved',
'type': 'comment'
}
];
$http({
method: 'POST',
url: 'http://www.domain.com/wp-json/wp/v2/comments?post=' + $scope.postID,
data: commentForm
}).then(function successCallback(response) {
console.log(response);
}, function errorCallback(response) {
});
$scope.showCommentForm = false;
$scope.showCommentButton = true;
};
When I log commentForm, all the properties are set. But none of them are inserted into the database. What am I doing wrong? The response of the $http Post is a 201, so it seems successful.