python - python http.client:如何在正文中使用 multipart/form-data 内容类型进行 POST 调用
问题描述
我正在尝试调用一个以 json 为内容的端点。
我试过这个
def upload():
connection = http.client.HTTPSConnection(self.url)
headers = { 'Content-Type': 'multipart/form-data'}
connection.request("POST", "/",body=json.dumps(self.myjson), headers)
我的json的内容是这样的
{"file": { "version":"2.0", "path":"my path", "test": "content"}}
问题是当我使用邮递员并直接上传文件时,它可以工作。但是当我尝试这部分代码时,我遇到了这个错误:
nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.springframework.web.multipart.MultipartFile] for property 'file[0]': no matching editors or conversion strategy found
我该如何解决这个问题?
解决方案
推荐阅读
- c# - EF 代码首先无法对非复杂空对象进行提交
- java - 使用 Oltu 的 Java Web 服务验证不记名令牌的指南?
- javascript - Can't read child of object
- loops - 从匹配的变量 bash 中打印特定列
- excel - 用于选择多个下拉选项的 VBA 代码不适用于受保护的工作表
- python-3.x - Is there anything known about interfacing between Synergy DBL and Python
- reactjs - React 元素错误地报告窗口的宽度
- python - Print a variable output in a 400 empty message code using Python
- java - How to sort this HashMap while flattening/grouping it, using streams?
- excel - 我可以过滤数据以显示 VBA 中昨天日期的当前月份吗?