Closed inarie closed 1 year ago
Afaik, at this point, you should be using the rest
path instead of v2
. Can you please try checking if you can still make a request to https://api.linkedin.com/rest/posts?q=author&author=urn%3Ali%3Aorganization%3A2414183
(so with rest
instead of v2
)? Also, make sure you're using the xrestli protocol version 2.0 (you need to set this corresponding header), which is used by this library.
Could you please also give more info about the problem you're encountering when you make the request with this client library? What's the error in response.response.json()
, HTTP status code and posts
?
Afaik, at this point, you should be using the
rest
path instead ofv2
. Can you please try checking if you can still make a request tohttps://api.linkedin.com/rest/posts?q=author&author=urn%3Ali%3Aorganization%3A2414183
(so withrest
instead ofv2
)?
I've test with rest
and it's working as expected on Postman. On other hand, the problem remains using the RestliClient
.
Could you please also give more info about the problem you're encountering when you make the request with this client library? What's the error in
response.response.json()
, HTTP status code andposts
?
When using the client , I get this error:
{
"serviceErrorCode": 100,
"message": "Field Value validation failed in PARAMETER: Data Processing Exception while processing fields [/author]",
"status": 403
}
Using the sample of code I've send above, the request url stays like this: https://api.linkedin.com/rest/posts?q=author&author=(value:urn%3Ali%3Aorganization%3A2414183)
.
I've also tried it this way:
from linkedin_api.clients.restli.client import RestliClient
restli_client = RestliClient()
response = restli_client.finder(
resource_path="/posts",
finder_name="author",
query_params={
"author": ("urn:li:organization:2414183")
},
version_string="202212",
acccess_token=<THREE_LEGGED_ACCESS_TOKEN>
)
posts = response.elements
The request url stays something like this https://api.linkedin.com/rest/posts?q=author&author=(urn%3Ali%3Aorganization%3A2414183)
. As you can see, it almost achieves what I want, but it doesn't work. (I also tried without the parenthesis, but for some reason it doesn't work too)
Also, using a get
instead of a finder
and making some code adjustments, returns Method 'GET' is not supported for URI
error. A simple get
to /posts
also returns No virtual resource found
error with 404.
@inarie I was able to get the posts using the following code, which slightly different from both of your examples. Give it a try ;)
restli_client = RestliClient()
response = restli_client.finder(
resource_path="/posts",
finder_name="author",
query_params={
"author": "urn:li:organization:2414183"
},
version_string="202212",
access_token="my_access_token"
)
posts = response.elements
Note 1: your access token should have been generated using the suitable scopes, etc.
Note 2: the syntax of the values in the query_params
dictionary may change in newer API versions. See e.g. https://github.com/linkedin-developers/linkedin-api-python-client/issues/39
Hi! Using the Community Management API, I'm attempting to get a company's most recent posts. I'm having some trouble passing the parameters, though. What I have is this:
This is the endpoint I'm attempting to reach: (I tested it using Postman, and it works as expected)
https://api.linkedin.com/v2/posts?q=author&author=urn%3Ali%3Aorganization%3A2414183