LinkedIn API returns “*** 不存在”

LinkedIn API returns "*** does not exist"

我有一个 LinkedIn 开发者应用程序连接到公司页面,其中包含已批准的 'Marketing Developer Platform' 产品。我正在尝试从 Google Sheets 脚本调用任何组织端点(“organizationPageStatistics”、“organizationalEntityFollowerStatistics”等),我拥有 'rw_organization_admin' 权限并且令牌对该权限有效.每次我收到消息中包含 'does not exist' 的 404 响应。

这是我正在使用的 URL 的示例;

https://api.linkedin.com/v2/organizationalEntityFollowerStatistics?q=organizationalEntity&organizationalEntity=urn%3Ali%3Aorganisation%3A{appId}&oauth2_access_token={access_token}

这是我在 Google 表格脚本中的内容;

  var data = {"X-Restli-Protocol-Version":"2.0.0"};
  var options = {'method' : 'post',
                 'contentType': 'application/json',
                 'payload' : JSON.stringify(data)
                };
  
  var LIData = UrlFetchApp.fetch("https://api.linkedin.com/v2/organizationalEntityFollowerStatistics?q=organizationalEntity&organizationalEntity="+LINKEDIN_COMPANY_URN_URLENCODED+"&oauth2_access_token="+LINKEDIN_ACCESS_TOKEN, options);

  Logger.log(JSON.parse(LIData)); 

非常感谢任何帮助。

似乎您不需要对 organizationalEntity 字段进行编码,此 curl API 调用工作正常(此示例使用 Test Organizations 但也适用于真实公司页面):

curl -H "Authorization: Bearer <aouth_token>" \
"https://api.linkedin.com/v2/organizationalEntityFollowerStatistics?q=organizationalEntity&organizationalEntity=urn:li:organization:2414183"

https://api.linkedin.com/v2/organizationalEntityFollowerStatistics?q=organizationalEntity&organizationalEntity=urn:li:organization:2414183&oauth2_access_token=<access_token>

将 return :

{
  "paging": {
    "start": 0,
    "count": 10,
    "links": []
  },
  "elements": [
    {
      "followerCountsByAssociationType": [
        {
          "followerCounts": {
            "organicFollowerCount": 894,
            "paidFollowerCount": 0
          }
        },
        {
          "followerCounts": {
            "organicFollowerCount": 150,
            "paidFollowerCount": 0
          },
          "associationType": "EMPLOYEE"
        }
      ],
      "followerCountsByRegion": [
        {
          "region": "urn:li:region:84",
          "followerCounts": {
            "organicFollowerCount": 101,
            "paidFollowerCount": 0
          }
        },
        {
          "region": "urn:li:region:7127",
......

}