问题
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