测试使用 Cloudflare API 来删除 DNS 记录报错

2023-02-07 17:23:16 +08:00
 Microcharon

测试使用 Cloudflare 的 API 来删除对应域名的 DNS 记录,对应的测试域名中有预先添加一条 A 记录

https://api.cloudflare.com/#dns-records-for-a-zone-delete-dns-record

curl -X DELETE "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$DNS_ID" \
     -H "X-Auth-Email: $EMAIL" \
     -H "X-Auth-Key: $GLOBAL_KEY" \
     -H "Content-Type: application/json"

报错如下,提示没有 DNS 记录

{"result":null,"success":false,"errors":[{"code":81044,"message":"Record does not exist."}],"messages":[]}

疑惑了很久,不清楚为什么会出错,求大佬解答

1395 次点击
所在节点    Cloudflare
2 条回复
bootvue
2023-02-07 17:28:22 +08:00
先 list /details 查询一下 看有没有
Microcharon
2023-02-07 17:48:19 +08:00
@bootvue

谢谢,list 出测试域名的 DNS 记录后才发现原来是 DNS_ID 和 ACCOUNT_ID (账户 ID )混淆了,以为 DNS_ID 就是 ACCOUNT_ID ,列出来才知道 DNS_ID ,这下 success 了

{"result":[{"id":"bd8401829beac46cf0zc44ce93407a05","zone_id":"1659x52d329x1519x9e6x36cc40a56bf","zone_name":"jazzcat.eu.org","name":"jazzcat.eu.org","type":"A","content":"107.185.3.1","proxiable":true,"proxied":true,"ttl":1,"locked":false,"meta":{"auto_added":false,"managed_by_apps":false,"managed_by_argo_tunnel":false,"source":"primary"},"comment":null,"tags":[],"created_on":"2023-02-07T07:48:26.041466Z","modified_on":"2023-02-07T07:48:26.041466Z"}],"success":true,"errors":[],"messages":[],"result_info":{"page":1,"per_page":100,"count":1,"total_count":1,"total_pages":1}}

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/914002

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX