"202301", "X-Restli-Protocol-V" /> "202301", "X-Restli-Protocol-V" /> "202301", "X-Restli-Protocol-V"/>

LinkedIn comment api not working, wrong path variables

138 Views Asked by At

The comments linkedIn api is not working like I would expect:

My code:

 $res = Http::withHeaders([
                    "LinkedIn-Version" => "202301",
                    "X-Restli-Protocol-Version" => "2.0.0",
                ])
                    ->withToken($post->account->bearer_token)
                    ->post(
                        sprintf(
                            env("LINKEDIN_API") . "socialActions/%s/comments",
                            $postId
                        ),
                        [
                            "actor" => $post->account->account_id,
                            "object" => $postId,
                            "message" => [
                                "text" => $post->linkedin_first_comment,
                            ],
                        ]
                    );

The url is this:

https://api.linkedin.com/rest/socialActions/urn:li:share:7037368272257712128/comments

Object id:

urn:li:share:7037368272257712128

But I keep receiving:

Syntax exception in path variables

What can be wrong here? Went through the docs lots of times.

1

There are 1 best solutions below

0
Allan Charles On

Use link:

https://api.linkedin.com/rest/socialActions/urn:li:share:CODE/comments

add header:

headers={'Authorization': 'Bearer 'TOKEN,'LinkedIn-Version': "202209"}

Remove: X-Restli-Protocol-Version

Hope this helps.