I can’t add a IP to my list
curl -X POST "https://api.cloudflare.com/client/v4/accounts{redacted}/items" \
-H "X-Auth-Email: my_email" \
-H "X-Auth-Key: my_global_token" \
-H "Content-Type: application/json"\
--data '[{ip":"{redacted}"}]'
error:
{
"result": null,
"success": false,
"errors": [
{
"code": 10026,
"message": "filters.api.invalid_json"
}
],
"messages": null
}
curl: (3) bad range specification in URL position 2:
[{"id":"","ip":"{redacted}","comment":""}]
sandro
#2
For starters, that’s not a valid JSON syntax, so the error message would be accurate.
Plus, blocking a proxy address will be a bit pointless, as you will never get a request with such an address anyhow.
sandro, thanks for answer.
Please, answer the corect JSON syntax in my example.
fritex
#4
Make sure you’ve created an list first.
Gather all the data you need.
--data '[{"ip":"162.158.129.67/32"}]'
→ you are missing starting double quote "
and please use IP address in a CIDR notation.
Use below, replace YOUR_ACCOUNT_ID
, YOUR_LIST_ID
, [email protected]
and YOUR_GLOBAL_API_KEY
with your values:
curl -X POST "https://api.cloudflare.com/client/v4/accounts/YOUR_ACCOUNT_ID/rules/lists/YOUR_LIST_ID/items" \
-H "X-Auth-Email: [email protected]" \
-H "X-Auth-Key: YOUR_GLOBAL_API_KEY" \
-H "Content-Type: application/json" \
--data '[{"ip":"162.158.129.67/32"}]'
Successfull output response should be:
{
"result": {
"operation_id": "SOME_HASH"
},
"success": true,
"errors": [],
"messages": []
}
You can also verify and re-check if the IP is added to your List by navigating to the Manage Account → Configurations → Lists.
Helpful article from the Cloudflare API docs:
sandro
#5
Well, you need a valid JSON syntax. Use one of the available format checkers to verify that.
sandro
#6
Plus, you really don’t need to block that address.
no, not work
curl: (3) bad range specification in URL position 2:
[{"ip":"162.158.129.67/32"}]
sandro
#8
What command did you exactly run?
And why do you want to block that address? There’s no point.
fritex
#9
I am missing the part where it is stated to block it? 
The List can be used to allow too, or not?
sandro
#10
It’s best you post a screenshot.
sandro
#11
Which is equally pointless. The whole address does not make sense here.
1 Like
sandro
#12
I just ran that very request and it worked just fine. Which brings us back to
The list is only for block some IP. This IP is just for example
sandro
#14
Well, that IP you don’t need to block as mentioned. And any other IP address will still work.
sandro
#16
The screenshot of the response is naturally not so useful and, of course, I meant what you are sending, because that’s where you make the mistake 
sandro
#17
And yes, redact the API key.
Auth-Key is ok. on GET I have a success result.
On POST, I have error
sandro
#19
I did not ask you to use GET I asked you to post a screenshot.
Sorry, but we are going in circles.
system
closed
#20
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.