Skip to main content

Standard Interface

commentOnPost

This method allows you to leave a comment on a post.


try {
  const workflowId = await linkedapi.commentOnPost.execute({
    postUrl: "https://www.linkedin.com/posts/username_activity-id",
    text: "Great insights! I completely agree with your perspective on this topic.",
    companyUrl: "https://www.linkedin.com/company/company1"
  });
  
  const { errors } = await linkedapi.commentOnPost.result(workflowId);
  
  // The list of possible execution errors is below
  if (errors && errors.length > 0) {
    console.warn('Workflow completed with execution errors:');
    errors.forEach(error => {
      console.warn(` - Type: ${error.type}, Message: ${error.message}`);
    });
  } else {
    console.log('Workflow completed successfully. Data:', data);
  }
} catch (e) {
  // A list of all critical errors can be found here:
  // https://linkedapi.io/sdks/handling-results-and-errors/#handling-critical-errors
  if (e instanceof LinkedApiError) {
    console.error(`Critical Error - Type: ${e.type}, Message: ${e.message}`);
  } else {
    console.error('An unexpected, non-API error occurred:', e);
  }
}

# Python SDK is coming soon!
#
# You can always use Linked API through HTTP
# https://linkedapi.io/docs/

// Go SDK is coming soon!
//
// You can always use Linked API through HTTP
// https://linkedapi.io/docs/

Params

  • postUrl â€“ LinkedIn URL of the post to comment.
  • text â€“ comment text, must be up to 1000 characters.
  • companyUrl (optional) – LinkedIn company page URL. When provided, the comment will be posted on behalf of the company. Requires content admin access to the company page.

Data

The method doesn't return any data.

Errors

  • postNotFound – provided URL is not an existing LinkedIn post.
  • commentingNotAllowed – commenting is not allowed on this post. This could be due to the post author's privacy settings, LinkedIn restrictions on commenting, or because the post type does not support comments.
  • noPostingPermission â€“ no permission to comment on behalf of this company.