Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mediaUpload/uploadedVideo Returns 504 Gateway Timeout frequently

Tags:

linkedin-api

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,
        )
like image 775
MichaelWClark Avatar asked Oct 21 '25 03:10

MichaelWClark


1 Answers

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"}
        ]
    }
like image 158
Maxim Pak Avatar answered Oct 27 '25 08:10

Maxim Pak