curl命令工作正常,但在使用python时返回状态代码400
curl -i --upload-file "/Users/peter/Desktop/superneatimage.png" --header "Authorization: xxxxxx redacted" 'https://api.linkedin.com/mediaUpload/C5522AQGTYER3k3ByHQ/feedshare-uploadedImage/0?ca=vector_feedshare&cn=uploads&m=AQJbrN86Zm265gAAAWemyz2pxPSgONtBiZdchrgG872QltnfYjnMdb2j3A&app=1953784&sync=0&v=beta&ut=2H-IhpbfXrRow1'
Python
URL = "https://api.linkedin.com/mediaUpload/C5622AQEgpDjq-5lt3w/feedshare-uploadedImage/0?ca=vector_feedshare&cn=uploads&m=AQJcz8wFt-0gZQAAAXJ_zhVP13hra1LIIu-fTX8QY9G4z6JcqRd6PXv_vw&app=68078486&sync=0&v=beta&ut=0zcFClAHwoHVg1
"
image = open("/Users/peter/Desktop/superneatimage.png", "rb")
file = {
"upload-file": image
}
headers = {
"X-Restli-Protocol-Version": "2.0.0",
"Authorization": f"Bearer {accessToken}"
}
action = requests.post(url, files=file, headers=headers)
print(action.status_code)
python输出
400
使用file read并将读取的图像传递给请求方法中的数据参数。请参阅下面的代码
相关问题 更多 >
编程相关推荐