I am trying to create a new post through the wp-rest API using a mobile app. To do this, I need to log in with a form. The authentication with json api auth is successful when I submit my username and password. However, when I attempt to create a new post with the wp-rest API, I encounter an error saying "You don't have permission to do this." Even though I am logged in!
Here is my code:
var data={"title":"Hello World!","content_raw":"Content","excerpt_raw":"Excerpt"};
$scope.register = function() {
$http({
method: 'POST',
url: 'http://url.com/provawp/wp-json/wp/v2/posts',
data: data,
headers: {'Content-Type': 'application/json'}
})
.success(function(data, status, headers, config) {
alert("City added successfully!");
})
.error(function(data, status, headers, config) {
}).
catch(function (error) {
alert("Error!");
console.log("error : " + JSON.stringify(error) );
});
}