Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fetching Comments of Comments with the LinkedIn API

Tags:

linkedin-api

The LinkedIn docs state how to collect comments of a comment here, but they seem to be incorrect. It says to make a GET request that looks like this:

https://api.linkedin.com/v2/socialActions/urn:li:comment:(activity:6273189577469632512,6275822846992351232)/comments

but when I try that all I get back is a 400 error with the message:

Syntax exception in path variables

Is this the correct formatting of the comment urn? I've tried encoding it like with other requests, but that returns back the same result. Seeing a working example of this request would really help.

like image 636
Calvin L Avatar asked Nov 16 '25 23:11

Calvin L


2 Answers

After talking to LinkedIn API's support, I have the answer to why this wasn't working. A lot of the documentation contains these notes:

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

I thought that those notes meant that all v2 requests are meant to have their headers contain X-Restli-Protocol-Version: 2.0.0, but in actuality, it is only the endpoints where that is specified in the pages of the documentation. In other words, using that header for endpoints where it isn't needed can cause some of the requests to fail in ways that aren't clear from the error message. Removing that from the header gave the correct response.

like image 115
Calvin L Avatar answered Nov 18 '25 21:11

Calvin L


In fact the v2 protocol ask to url encode variable path. So better to stay in v2 protocol and url encode the "urn:li:comment:...."

https://learn.microsoft.com/en-us/linkedin/shared/api-guide/concepts/protocol-version#single-resource-key

like image 28
Julien ARBEY Avatar answered Nov 18 '25 20:11

Julien ARBEY



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!