When uploading videos to LinkedIn via API we get very frequent 504 timeout errors. We have added in backoff and retry mechanisms, but still get a large percentage of failures due to this. We can manually retry the uploads and eventually they work without changing anything.
Anyone else navigate this issue? Anything we can do with our uploads to reduce or prevent these errors? Some of our upload code below:
data = self.session.post(
url="/assets",
params={"action": "registerUpload"},
json={
"registerUploadRequest": {
"owner": owner,
"recipes": ["urn:li:digitalmediaRecipe:feedshare-video"],
"serviceRelationships": [
{"identifier": "urn:li:userGeneratedContent", "relationshipType": "OWNER"}
],
"supportedUploadMechanism": ["SYNCHRONOUS_UPLOAD"],
}
},
)
upload_url = data["value"]["uploadMechanism"][
"com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest"
]["uploadUrl"]
response = self.session.put(
url=upload_url,
headers={"Content-Type": "application/binary"},
data=media.file.open("rb"),
return_response=True,
)
We've been experiencing the same issue and what has worked for us was removing supportedUploadMechanism option from the registerUploadRequest.
So the updated JSON should look like the following for you
"registerUploadRequest": {
"owner": owner,
"recipes": ["urn:li:digitalmediaRecipe:feedshare-video"],
"serviceRelationships": [
{"identifier": "urn:li:userGeneratedContent", "relationshipType": "OWNER"}
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With