使用 WP Rest API 和应用程序密码时收到“抱歉,您无权以该用户身份创建帖子”

问题描述 投票:0回答:1

我想使用 REST API 和应用程序密码身份验证创建帖子。

因此,我使用“添加新应用程序密码”创建凭据

然后我跑了:

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"}'

但是我得到了:

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

通常,使用最新版本的WP,我不需要安装任何插件。

有什么想法吗?

谢谢

wordpress wordpress-rest-api
1个回答
0
投票

您应该在 --user 中提供您的

用户名
代替您的应用密码名称。

© www.soinside.com 2019 - 2024. All rights reserved.