Please refer to the following code.
you need to generate the nonce first to create a post.
$.ajax({
// get the nonce
dataType: 'jsonp',
url: '/api/get_nonce/?controller=posts&method=create_post',
type: 'GET',
success: function (data) {
// create the post
$.ajax({
url: '/api/create_post/',
type: 'POST',
dataType: 'jsonp',
data: {nonce: data.nonce, status:'xxxx',title:'xxxx', content:'xxxx'},
success: function (data) {
},
error: function (data) {
console.log('error');
}
});
},
error: function (data) {
console.log('error');
}
});
nonce is the key for creating a post.