最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

linkedin api - v2ugcPosts is failing author :: "urn:li:person:12344xxx" does not match urn:li:company:\d+|urn:

programmeradmin0浏览0评论

I am trying to post to v2/ugcPosts is getting a 420 error.

Error: 422 {"message":"ERROR :: /author :: \"urn:li:person:181815873\" does not match urn:li:company:\\d+|urn:li:member:\\d+\n","status":422}

I checked the access token and it looks good.

Here is the Sample code

import requests

ACCESS_TOKEN = '<Access Code>'
AUTHOR_URN = "urn:li:person:1234q3123"  # Replace with your LinkedIn person URN

url = ''

post_data = {
    "author": AUTHOR_URN,
    "lifecycleState": "PUBLISHED",
    "specificContent": {
        "com.linkedin.ugc.ShareContent": {
            "shareCommentary": {
                "text": "This message is posted using python"
            },
            "shareMediaCategory": "NONE"
        }
    },
    "visibility": {
        "com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
    }
}

headers = {
    'Authorization': f'Bearer {ACCESS_TOKEN}',
    'Content-Type': 'application/json',
    'X-Restli-Protocol-Version': '2.0.0'
}

response = requests.post(url, headers=headers, json=post_data)

if response.status_code == 201:
    print("Post shared successfully on LinkedIn!")
else:
    print("Error:", response.status_code, response.text)

I dont have access to fetch the urn. So I got the urn of the profile from the customer care.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论