在失败的帖子中获取此错误。
from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
import urllib
# Register the streaming http handlers with urllib
register_openers()
# Start the multipart/form-data encoding of the file "sample.png"
# headers contains the necessary Content-Type and Content-Length
# datagen is a generator object that yields the encoded parameters
datagen, headers = multipart_encode({"image": open("sample.png")})
request = urllib.request.Request("https://my_sample_api_url", datagen, headers)
request.add_header("Authorization", "Basic ***********")
print(urllib.request.urlopen(request).read())
尽管该帖子已发布。