I have implemented all three steps for sharing an image post on linkedin using create image share api described below. But created posts are not visible on my linkedin feed/posts or recent activities.
https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/share-on-linkedin#create-an-image-share
First time I created the post is visible using API and it returned {"id":"urn:li:share:6521244543193575424"}
Posted Visible post url:
https://www.linkedin.com/feed/update/urn:li:share:6520269375554060288/
Second time onwards created with same code below returns similar response with created post id and with 201 created status code but post is not visible on linkedin.
For example this post https://www.linkedin.com/feed/update/urn:li:share:6521027773560119296
I checked my linkedin profile but couldn't find my posts any where.
Code for Final function for posting I am using(3rd step for creating image share using the documentation link above) :
 def share_on_linkedin(self, asset, title, description):
    # asset = "urn:li:digitalmediaAsset:C5122AQEAatG9rZ7MhQ"
    headers = {
    'Content-Type':'application/json',
    'X-Restli-Protocol-Version': '2.0.0',
    'Authorization': 'Bearer '+Constant.ACCESS_TOKEN
    }
    payload = {
        "author": "urn:li:person:leRbOTCFKK",
        "lifecycleState": "PUBLISHED",
        "specificContent": {
            "com.linkedin.ugc.ShareContent": {
                "shareCommentary": {
                    "text": description
                },
                "shareMediaCategory": "IMAGE",
                "media": [
                    {
                        "status": "READY",
                        "description": {
                            "text": "Center stage!"
                        },
                        "media": asset,
                        "title": {
                            "text": title
                        }
                    }
                ]
            }
        },
        "visibility": {
            "com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
        }
    }
    try:
        data = json.dumps(payload, sort_keys=True, indent=4)
        url = "https://api.linkedin.com/v2/ugcPosts"
        response = requests.post(url , headers=headers, data=data )
        print response.text
        result = json.loads(response.text)  
        if response.status_code==200 or response.status_code==201:
            print response.text
            print response.headers              
            posted_url =  "https://www.linkedin.com/feed/update/"+result['id']
                            print posted_url 
            return True, posted_url
        return False, None
    except Exception as e:
        print e
Output:
{"id":"urn:li:share:6521245116978552832"}
{'Content-Length': '41', 'X-RestLi-Protocol-Version': '2.0.0', 'X-Li-Pop': 'prod-tmu1', 'X-LI-ResponseOrigin': 'RGW', 'X-RestLi-Id': 'urn:li:share:6521245116978552832', 'X-LI-UUID': 'aKr30Z+1kxWAo4kEzioAAA==', 'X-LI-Route-Key': '"b=SB83:g=115:u=3:i=1554785994:t=1554872227:s=AQH26er48VUD_YiXQIgAqujebI53eswQ"', 'X-Li-Fabric': 'prod-lsg1', 'Connection': 'keep-alive', 'Location': '/ugcPosts/urn%3Ali%3Ashare%3A6521245116978552832', 'Set-Cookie': 'lidc="b=SB83:g=115:u=3:i=1554785994:t=1554872227:s=AQH26er48VUD_YiXQIgAqujebI53eswQ"', 'Date': 'Tue, 09 Apr 2019 04:59:55 GMT', 'X-LI-Proto': 'http/1.1', 'Content-Type': 'application/json'}
Posted url constructed from above successful response is: https://www.linkedin.com/feed/update/urn:li:share:6521245116978552832
But this post is not visible.
Can anybody help me with this.
Thanks!
You may need to verify your media asset is available and ready to be posted before submitting your ugcPosts request.
After you've uploaded your image binary, submit a request to the /assets API and check the status is AVAILABLE
GET https://api.linkedin.com/v2/assets/C5122AQEAatG9rZ7MhQ
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