wordpresswordpress-rest-api

Get "Sorry, you are not allowed to create posts as this user" when using WP Rest API and Application Password


I want to create a post using rest API and Application Password authentification.

So I create credentials using the "Add New Application Password"

enter image description here

and then I run :

curl --user "veptuneapp:APPLICATION_PASSWORD" -X POST \
-H "Content-Type: application/json" \
-i https://www.example.com/wp-json/wp/v2/posts \
-d '{"title": "foo bar", "content": "test"}'

But I got :

{"code":"rest_cannot_create","message":"Sorry, you are not allowed to create posts as this user.","data":{"status":401}}

Normally, with the lasts version of WP, I don't need to install any plugin.

Any idea?

Thanks


Solution

  • You should present your username in place of your app password name in --user.