How to delete an IP from a list using the API?

Why is this failing to delete the IP from the list? and how i could delete the IP using its "name" like 111.111.111.111 instead of querying its id?
$accountId = "..."
$itemId = "4514a...
$body = @{
items = @(
@{ id = $itemId }
)
}

$headers = @{
Authorization = "Bearer ..."
"Content-Type" = "application/json"
}
$lists = Invoke-RestMethod -Method Delete `
-Uri "https://api.cloudflare.com/client/v4/accounts/$accountId/rules/lists/$listId/items" `
-Headers $headers `
-Body ($body | ConvertTo-Json -Depth 5)
Write-Host ($lists | ConvertTo-Json -Depth 5) -ForegroundColor Green

Write-Host ($body | ConvertTo-Json -Depth 5)
$accountId = "..."
$itemId = "4514a...
$body = @{
items = @(
@{ id = $itemId }
)
}

$headers = @{
Authorization = "Bearer ..."
"Content-Type" = "application/json"
}
$lists = Invoke-RestMethod -Method Delete `
-Uri "https://api.cloudflare.com/client/v4/accounts/$accountId/rules/lists/$listId/items" `
-Headers $headers `
-Body ($body | ConvertTo-Json -Depth 5)
Write-Host ($lists | ConvertTo-Json -Depth 5) -ForegroundColor Green

Write-Host ($body | ConvertTo-Json -Depth 5)
Im getting as response and output:
{
"result": {
"id": "items"
},
"success": true,
"errors": [

],
"messages": [

]
}

{
"items": [
{
"id": "4514a..."
}
]
}
{
"result": {
"id": "items"
},
"success": true,
"errors": [

],
"messages": [

]
}

{
"items": [
{
"id": "4514a..."
}
]
}
"success" but the item is not being deleted at the website list. I'm following these: Forum post: https://community.cloudflare.com/t/delete-list-items-example-please/528757/9?u=oliverr Documentation: https://developers.cloudflare.com/api/resources/rules/subresources/lists/subresources/items/methods/create/#(merged%20schema)%20%3E%20(property)%20result
Cloudflare API | Rules Lists › Lists › Items › Create List Items
Interact with Cloudflare's products and services via the Cloudflare API
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?