2
votes

Followed this doc: https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/rich-media-shares to upload images to reference in a organization share in LinkedIn.

Successfully uploaded the image using Assets API. The URN is in this format - urn:li:digitalmediaAsset:XXX

Retrieving asset information using the Asset ID from the digitalmediaAsset URN shows the following status:

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

But when I write a share using Assets URN -

POST https://api.linkedin.com/v2/shares

{
    "content": {
        "contentEntities": [
            {
                "entity": "urn:li:digitalmediaAsset:XXX"
            }
        ],
        "description": "content description",
        "title": "Test Share with Content"
    },
    "distribution": {
        "linkedInDistributionTarget": {}
    },
    "subject": "Test Share Subject",
    "text": {
        "text": "Test Share!"
    },
    "owner":"urn:li:organization:YYY"
}

I get the following error:

{"message":"Invalid content entity type!","status":400}

Any idea what I am doing wrong?

1
Did you ever find a solution to this issue? I am having a similar issue that I can't seem to figure out.Trendy
@Trendy, See my answer below.kfoozminus

1 Answers

5
votes

Add shareMediaCategory field here like this:

POST https://api.linkedin.com/v2/shares

{
    "content": {
        "contentEntities": [
            {
                "entity": "urn:li:digitalmediaAsset:XXX"
            }
        ],
        "description": "content description",
        "title": "Test Share with Content",
        "shareMediaCategory": "IMAGE"
    },
    "distribution": {
        "linkedInDistributionTarget": {}
    },
    "subject": "Test Share Subject",
    "text": {
        "text": "Test Share!"
    },
    "owner":"urn:li:organization:YYY"
}

See the documentation for details: https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/share-api#using-images-for-shares