Bad request: Attempting to associate a ugc with an asset that's not owned by the author
Asked Answered
I

1

8

I'm trying to migrate my app from LinkedIn API v1 to v2. I'm currently looking at sharing images (natively) to my personal LinkedIn profile.

I'm following the official docs here: https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/share-on-linkedin#create-an-image-share

To register the image I made the following POST request: to https://api.linkedin.com/v2/assets?action=registerUpload

{
    "registerUploadRequest": {
        "recipes": [
            "urn:li:digitalmediaRecipe:feedshare-image"
        ],
        "owner": "urn:li:person:9PyfTxBTFY",
        "serviceRelationships": [
            {
                "relationshipType": "OWNER",
                "identifier": "urn:li:userGeneratedContent"
            }
        ]
    }

}

I got the success response:

{
    "value": {
        "uploadMechanism": {
            "com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest": {
                "headers": {},
                "uploadUrl": "https://api.linkedin.com/mediaUpload/C4D22AQEGOHxBzKUXvw/feedshare-uploadedImage/0?ca=vector_feedshare&cn=uploads&m=AQLhYJm0KOaTCgAAAWhSDplI-Lzlfh7lOsd8D5qBcz0aJ2bf1fwIfnh8ow&app=5212106&sync=0&v=beta&ut=0rKn179ebIA8A1"
        }
    },
    "mediaArtifact": "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:C4D22AQEGOHxBzKUXvw,urn:li:digitalmediaMediaArtifactClass:feedshare-uploadedImage)",
    "asset": "urn:li:digitalmediaAsset:C4D22AQEGOHxBzKUXvw"
    }
}

I successfully uploaded an image as binary using the returned uploadUrl:

curl -i --upload-file PATH_TO_FILE --header "Authorization: Bearer TOKEN" 'https://api.linkedin.com/mediaUpload/C4D22AQEGOHxBzKUXvw/feedshare-uploadedImage/0?ca=vector_feedshare&cn=uploads&m=AQLhYJm0KOaTCgAAAWhSDplI-Lzlfh7lOsd8D5qBcz0aJ2bf1fwIfnh8ow&app=5212106&sync=0&v=beta&ut=0rKn179ebIA8A1'

To confirm that the image is ready for use, I checked the status of the asset with the GET https://api.linkedin.com/v2/assets/C4D22AQEGOHxBzKUXvw which returned

{
    "serviceRelationships": [
        {
            "identifier": "urn:li:userGeneratedContent",
            "relationshipType": "OWNER"
        }
    ],
    "recipes": [
       {
            "recipe": "urn:li:digitalmediaRecipe:feedshare-image",
            "status": "AVAILABLE"
        }
    ],
    "mediaTypeFamily": "STILLIMAGE",
    "created": 1547564914979,
    "lastModified": 1547564994321,
    "id": "C4D22AQEGOHxBzKUXvw",
    "status": "ALLOWED"
}

Based on the docs, I can now simply reference the asset URN in the UGC post.

This is the test image post I'm trying to share using the https://api.linkedin.com/v2/ugcPosts endpoint

{
    "author": "urn:li:person:9PyfTxBTFY",
    "lifecycleState": "PUBLISHED",
    "specificContent": {
        "com.linkedin.ugc.ShareContent": {
            "shareCommentary": {
                "text": "Testing LinkedIn image shares"
            },
            "shareMediaCategory": "IMAGE",
            "media": [
                {
                    "status": "READY",
                    "description": {
                        "text": "Some text"
                    },
                    "media": "urn:li:digitalmediaAsset:C4D22AQEGOHxBzKUXvw",
                    "title": {
                        "text": "Some title"
                    }
                }
            ]
        }
    },
    "visibility": {
        "com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
    }
}

But I keep getting the error:

{
    "message": "Attempting to associate a ugc with an asset that's not owned by the author",
    "status": 400
}

The above request works perfectly when trying to share a status update or a link attachment.

I haven't tried it with videos yet (similar approach) since I assume I will face the same problem. I haven't tried sharing as an organization either since I need to be accepted to the LinkedIn Marketing Developer Program first.

Impenetrable answered 15/1, 2019 at 15:24 Comment(12)
Did you resolve your issue? I am getting "Bad request"Decanal
Haven't tried a new request yet, but the above one is now returning a slightly different message: "com.linkedin.publishing.util.common.ResponseException: Attempting to associate a ugc ..." Maybe LinkedIn guys are still working on it.Impenetrable
I receive the same error "com.linkedin.publishing.util.common.ResponseException: Attempting to associate a ugc with an asset that's not owned by the author". Any news about the problem ?Firecrest
@ErvinKalemi did you resolve the issue with "Attempting to associate a ugc with an asset that's not owned by the author"Decanal
I've stopped working on it until there's an update from LinkedIn. I do test the call every day and so far nothing has changed.Impenetrable
What are you using to authenticate? I have the same issue and building on ROR with gem 'omniauth-linkedin-oauth2' to auth the user.Alejandro
@DanielWillems that's what I'm using too. Make sure to upgrade to v1.0.0 which is for LinkedIn API v2 github.com/decioferreira/omniauth-linkedin-oauth2/pull/44Impenetrable
Also there shouldn't be an issue with the authentication since other calls succeed.Impenetrable
I don't disagree. Since I am running into the same issue (with much frustration) I was looking for anything. We actually were using an older version of the gem so I was actually still authing with V1. Thanks for the tip! Even after that change I am getting the same results.Alejandro
Thanks for bringing this issue to our attention. Sorry for the inconvenience. Everything in the calls above is correct which made it very easy to replicate the behavior and identify the underlying issue. I can confirm that this issue is now resolved. Thanks for your patience. -- LinkedIn Developer SupportBushire
I can also confirm that this now works. Thank you @S.Kiel for taking care of this.Impenetrable
@S.Kiel, any idea why nearly the same calls for video posts fail with the error "com.linkedin.publishing.util.common.ResponseException: urn:li:developerApplication:5212106 does not have permission to create ugc posts". Uploading the video asset works perfectly, but the last call for creating the UGC post with the available video asset, fails. This is again for posting to a personal profile. I haven't tried it with a company page yet as I'm still waiting to join the LinkedIn Marketing Partners program.Impenetrable
I
3

I can confirm that this has been fixed by the LinkedIn Developer Team. Follow the same steps as above and it should work perfectly, as long as the authenticated user has granted the w_member_social permission.

On the last request I now get 201 Created response with the header X-RestLi-Id containing the link to the new post urn:li:share:6494126499975700480.

https://www.linkedin.com/feed/update/urn:li:share:6494126499975700480

P.S. If you're re-trying an old request / registered upload, it won't work, so make sure you try it with a new asset. I believe the bug was when registering uploads.

Impenetrable answered 24/1, 2019 at 9:9 Comment(9)
Thanks for the update! I am still getting "recipes"=>[{"recipe"=>"urn:li:digitalmediaRecipe:feedshare-image", "status"=>"WAITING_UPLOAD"}] when I check assets after uploading the file. Right now I am needing to turn a url into a file, putting in a tmp folder and then uploading (so this could be my problem). Are you uploading files from your file system to Linkedin or using some sort of similar solution?Alejandro
Sorry I may have asked too soon. I am getting a bad response when I try and upload my binary of HTTP/1.1 401 Unauthorized\r\nServer. This doesn't make sense to me since I am able to make all the other calls successfully.Alejandro
I tested it using the terminal (on a Mac). Haven't had the chance to integrate it on my app yet.Impenetrable
I simply called curl -i --upload-file PATH_TO_FILE --header "Authorization: Bearer TOKEN" 'URL_FROM_REGISTER_UPLOAD'Impenetrable
Does the token you're using in the request have the w_member_social permission?Impenetrable
Yes I have that. We have been posting on V2 in production for a few months. I am also able to post fine with Article/URL and text via UGC. I am using Http party for getting Register URL and trying to post. I am not sure if there is some sort of conflict in making the request via the Gem.Alejandro
Let us continue this discussion in chat.Alejandro
Hi! Now It seems to work for me too. I can receive correct urn:li:share id. But when I try to open it I receive "System error message" smth like this: linkedin.com/feed/update/urn:li:share:6494153194871103488 . Did anybody meet this problem ? And there is nor update in my feed too.Firecrest
Was the asset available for use? When calling GET api.linkedin.com/v2/assets/YOUR_ASSET_ID, what's the response. I'm just assuming maybe the asset was invalid, thus the share post ended up in a bad state.Impenetrable

© 2022 - 2024 — McMap. All rights reserved.