LinkedIn API: Server error while listing UGC posts

笑着哭i 提交于 2021-02-07 20:42:55

问题


I'm getting a server error when trying to list all UGC posts for an organization.

I have followed the API documentation there: https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/ugc-post-api#find-ugc-posts-by-authors

I'm doing a GET request on this URL: https://api.linkedin.com/v2/ugcPosts?q=authors&authors=List(urn%3Ali%3Aorganization%3A6645672)

I added the Authorization header with the correct value.

The UGC posts should be returned, but instead I'm getting the following API response:

{
  'serviceErrorCode': 0,
  'message': 'java.lang.ClassCastException',
  'status': 500
}

And here are the response headers:

{
  'X-LI-ResponseOrigin': 'RGW',
  'X-Restli-Gateway-Error': 'true',
  'Content-Type': 'application/json',
  'Content-Length': '76',
  'X-Li-Fabric': 'prod-lor1',
  'Connection': 'keep-alive',
  'X-Li-Pop': 'prod-efr5',
  'X-LI-Proto': 'http/1.1',
  'X-LI-UUID': 'lsI6Y1fvpRUgJP1JhSsAAA==',
  'Set-Cookie': 'lidc="b=OB36:g=1813:u=339:i=1559916004:t=1559978523:s=AQE_uyAgsS2aohUoPQqxLGIDiYC9Gpfr"',
  'X-LI-Route-Key': '"b=OB36:g=1813:u=339:i=1559916004:t=1559978523:s=AQE_uyAgsS2aohUoPQqxLGIDiYC9Gpfr"'
}

For privacy reasons I'm not giving you the Access Token, but your team will have all the details with the request ID present in the response headers I just pasted above.

Thanks to the community or LinkedIn support team to help me debugging this error.

Best regards.


回答1:


As described in the note of the doc you refer:

All API requests are represented in protocol 2.0.0 and require the header X-Restli-Protocol-Version: 2.0.0.

You should add the header in the request, as example, the following request went fine:

curl -H "X-Restli-Protocol-Version: 2.0.0" "https://api.linkedin.com/v2/ugcPosts?q=authors&authors=List(urn%3Ali%3Aorganization%3A6645672)&oauth2_access_token=<a-valid-token>

Hope this help



来源:https://stackoverflow.com/questions/56505276/linkedin-api-server-error-while-listing-ugc-posts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!