IronPython请求错误:应为<type'bytes'>

2024-05-15 12:02:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我是python新手,我正在尝试用JSON发布到https API,我使用的是ironpython2.7和请求,python2.7 这是我的密码

import requests
import json

def PostData(uri, Timestamp, ProxyIP, ProxyPort, username, password, UserAgent, Joson):

   payload = {"Timestamp": Timestamp}   
   headers = {"user-agent": UserAgent,
              "ContentType" :"application/json"}

   r = requests.post(uri,params=payload,json=json.dumps(Joson))

   return r.text

但我总是犯错误:

IronPython Requests Error: expected <type 'bytes'>

即使我只是使用 requests.post(uri) 如何解决这个问题?谢谢你的帮助


Tags: httpsimportapijson密码defuripost