【发布时间】:2020-09-23 14:57:25
【问题描述】:
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'
蟒蛇
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
【问题讨论】:
标签: python curl python-requests linkedin-api