我正在尝试上传一个文件到网站,但没有成功。我需要获取文件的uuid才能在vinted.hu.上创建帖子。cookie和头文件没有问题,只有请求:'(
需要任何帮助!
文件接受按钮
<input data_testid="add-photos-input" name="photos" class="u-hidden" type="file" accept="image/*" multiple="">
发送照片的分片代码
with open('data/post/213.jpg', 'rb') as file:
async with session.post('https://www.vinted.hu/api/v2/photos',headers=headers, data={"photos": file}) as response:
print(await response.text())
结果
{"code":99,"message":"Sorry, there are some errors","message_code":"validation_error","errors":[{"field":"base","value":"param is missing or the value is empty: photo\nDid you mean? photos"}],"payload":{}}
发送照片的piece code 1
data = FormData()
data.add_field('photos',open('data/post/213.jpg', 'rb'), filename='213.jpg', content_type='image/*')
async with session.post('https://www.vinted.hu/api/v2/photos',headers=headers, data=data) as response:
print(await response.text())
结果1
{"code":99,"message":"Sorry, there are some errors","message_code":"validation_error","errors":[{"field":"base","value":"param is missing or the value is empty: photo\nDid you mean? photos"}],"payload":{}}
1条答案
按热度按时间rta7y2nd1#
在请求负载中使用
multipart/form-data
内容类型。