首页 > 解决方案 > 我正在尝试调用 cloudflare api“创建列表项”,但出现错误“需要类似字节的对象,而不是 'str'”。我如何解决它

问题描述

import json import requests ip = input('Put IP here:') comment = input('Put comment here:')

url = "https://api.cloudflare.com/client/v4/accounts/xxxxxxxxxxxxxx/rules/lists/xxxxxxxxxxxxxx/items" 有效载荷 = {(ip),(comment)}

headers = {“content-type”:“application/json”,“Accept-Charset”:“UTF-8”,“X-Auth-Email”:“xxxxxxxxxxxxx”,“X-Auth-Key”:“xxxxxxxxxx” }

response = requests.post(url,data=payload, headers=headers) 打印 (response.txt)

标签: python-3.xapicloudflare

解决方案


推荐阅读