如何在一个 python post 请求中发送两张图像
后的api,
编辑
这是我必须做的 我必须发送两个带有“bank_statement”键的图像,否则 API 将发送消息“必须提交恰好两个图像”。我对请求所做的事情是
> myfiles = {'bank_statement': open("DOC1.jpg", 'rb'),
> 'bank_statement': open("DOC1.jpg", 'rb')}
is_extractable = requests.post(Validate, files=myfiles)
但响应是
{'timestamp': '2022-03-01 10:00:43.354058', 'message': '正好两个 必须提交图像。', 'error': '错误请求', 'status': 400}
我不知道问题出在哪里。
This is the api
edited
what I have to do I have to send two images with the key "bank_statement" otherwise the API will send the message "Exactly two images must be submitted." What I am doing with the request is
> myfiles = {'bank_statement': open("DOC1.jpg", 'rb'),
> 'bank_statement': open("DOC1.jpg", 'rb')}
is_extractable = requests.post(Validate, files=myfiles)
But the response is
{'timestamp': '2022-03-01 10:00:43.354058', 'message': 'Exactly two
images must be submitted.', 'error': 'Bad Request', 'status': 400}
I can't figure out where is the problem is.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是你的字典不是由两个条目组成,而是只有一个条目。
给出输出
您可能需要添加两次,或者添加一个列表,请查看此答案。
The problem is that your dictionary is not consisting of two entries, but only one.
gives as output
You might have to add it twice, or add a list, look at this answer.
如果你想发送两个具有相同参数的图像,你可以创建一个列表
这里bank_statement是参数,打开闭包上的image1是我发送的文件的路径。
If you want to send two images with the one and same parameter you have create a list
Here bank_statement is parameter and image1 on open closure is path of files I have sent.