python - Cloudflare API 将代理参数默认为 false

标签 python linux api dns cloudflare

我使用一个 python 脚本,它允许我在配置/选择的 Cloudflare DNS 条目上自动更新我的 Raspberry Pi 的公共(public) IP。这是通过 Cloudflare API 完成的。

看起来 API 中的代理参数现在默认为 false,这会禁用 Cloudflare 保护。

我已经创建了 Cloudflare 支持票证并得到了以下答复:

在 api 调用中设置 proxied = true 将在更新记录时设置 Cloudflare 保护。

不幸的是,我还不会用 Python 编程,所以我无法解决这个问题。

原文:

data=json.dumps({'type': record['type'], 'name': record['name'], 'content': ip_address}),

我的尝试:

data=json.dumps({'type': record['type'], 'name': record['name'], 'content': ip_address, 'proxied':'true'}),

我在尝试将 proxied 设置为 true 时收到这些错误消息:

Updating the A record (ID 28b768cfd9760226648f3f22880bff7d) of (sub)domain www.******.com (ID 5129ccb06da9ae49f0a326ef945ff3e4) to **.**.***.**.
DNS record failed to update.
CloudFlare returned the following errors: [{u'error_chain': [{u'message': u"Invalid 'proxied' value, must be a boolean", u'code': 9003}], u'message': u'DNS Validation Error', u'code': 1004}].
CloudFlare returned the following messages: []
Updating the A record (ID f0269da1fab6dcad62c31755f98a6321) of (sub)domain ******.com (ID 5129ccb06da9ae49f0a326ef945ff3e4) to **.**.***.**.
DNS record failed to update.
CloudFlare returned the following errors: [{u'error_chain': [{u'message': u"Invalid 'proxied' value, must be a boolean", u'code': 9003}], u'message': u'DNS Validation Error', u'code': 1004}].
CloudFlare returned the following messages: []

完整的 python 脚本:
GitHub view
Raw

这样做的正确方法是什么?

提前致谢

最佳答案

'proxied':'true' 更改为 'proxied': True 以使其成为 bool 值而不是字符串。

关于python - Cloudflare API 将代理参数默认为 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56477450/

相关文章:

java与NFC通信(PC/SC)

javascript - 尝试以 HTML 格式显示 API 数据

rest - 什么是 Rest API

OpenWeather API 的 JSON 结果集未返回 Swift 中主词典的值

python - 如何让我的 Discord 机器人看起来像是正在打字?

Python 多处理管道 recv() 文档不清楚还是我遗漏了什么?

python - scapy 和 pypcap 丢包严重时如何嗅探 python 上的所有数据包?

linux - Virtualhost Document Root 更改整个服务器的 Web 根目录

Python DB2 - 找不到符号

未找到安卓 adb