Creating a post with WordPress REST-API

Hello everyone, i need to create a post with the WordPress Rest-API but i get an error 401 “Your userrolle has no rights to create posts.” I use the WordPress application passwort to authenticate. I created that on my admin user. Do you know what the problem could be?


const apiUrl = ‘https://page.local/wp-json/wp/v2/posts’;
const authToken = ‘fkQt z5LK Ewmk 7Sn6 UM1f A7xD’;

const postData = {

fetch(apiUrl, {
method: ‘POST’,
headers: {
‘Content-Type’: ‘application/json’,
‘Authorization’: `Bearer ${authToken}`,
body: JSON.stringify(postData),
.then(response => response.json())
.then(data => {
console.log(‘Post created successfully:’, data);
.catch(error => {
console.error(‘Error creating post:’, error);



This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer