I'm trying to make a Postman call to the Wordpress API to delete a block.
However, I keep getting a 403
. This user is used to add and delete pages, tags, and posts just fine using the Application Passwords
Plugin for authentication. The user is an Administrator
.
I have no idea why I don't have permissions. I can delete in the UI.
I suspect I am not adding a needed parameter to the creation call such as context or a template. But I don't know what values those should be. I hope someone here as experience with using Blocks in the REST API.
ERROR:
{
"code": "rest_cannot_delete",
"message": "Sorry, you are not allowed to delete this post.",
"data": {
"status": 403
}
}
I'm deleting these blocks using the API with a call like this:
curl -X DELETE \
'http://<IP_ADDRESS>/<SUBSUTE>/wp-json/wp/v2/blocks/59?force=1' \
-H 'Accept: */*' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Authorization: Basic <Token>' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Length: ' \
-H 'Host: <IP>' \
-H 'Postman-Token: <TOKEN>' \
-H 'User-Agent: PostmanRuntime/7.15.2' \
-H 'cache-control: no-cache'
I'm creating these blocks using the API with a call like this:
curl -X POST \
'http://<SITE>/<SUBSITE>/wp-json/wp/v2/blocks?title=BLOCKS%20TITLE&content=BLOCKS%20CONTENT' \
-H 'Accept: */*' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Authorization: Basic <TOKEN>' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Length: ' \
-H 'Host: <IP>' \
-H 'Postman-Token: <TOKEN>' \
-H 'User-Agent: PostmanRuntime/7.15.2' \
-H 'cache-control: no-cache'
--user "USERNAME:PASSWORD"
in the cURL request?Authorization: Basic <Token>
header. It's worked for everything else. <Token> is theusername:password
in Base64 encoded already.delete_blocks
permission? Try$user = get_userdata( 'USER ID' ); $user->add_cap( 'delete_blocks' );
and run the REST API request for deleting the block.wp_config.php
? I'm not trying to mess with any custom Rest API points. I'm actually building documentation on what's already there for anyone who wants to use the default Rest API. Just clearing up that none of this is for any Wordpress development. I'll try adding that and let you all know