Skip to main content

Getting Started

Handling results and errors

When you initiate any workflow, the execute() method immediately returns a workflowId for tracking. You can then use the result() method with this ID to get the workflow results when it's complete.


const workflowId = await linkedapi.checkConnectionStatus.execute({
  personUrl: "https://www.linkedin.com/in/john-doe"
});
const result = await linkedapi.checkConnectionStatus.result(workflowId);

# 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/
    

The structure of the object returned by result() depends on whether you use a predefined workflow or a custom workflow.

For predefined workflows

When using a standard, predefined method, result() returns a convenient object with two key fields:

  • data – typed object containing the successful result of the workflow.
  • errors – array of non-critical workflow execution errors, that may have occurred during the run, but did not stop the entire workflow. Each error object contains type and message fields.

const workflowId = await linkedapi.checkConnectionStatus.execute({
  personUrl: "https://www.linkedin.com/in/john-doe"
});
const result = await linkedapi.checkConnectionStatus.result(workflowId);

const data = result.data;
const errors = result.errors;

# 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/
    
For each predefined method, the specific structure of its data object and a list of possible errors are detailed on the corresponding page in the side navigation menu.

For custom workflows

When using customWorkflow, the result() method returns the raw completion object. This object contains the full execution context of the workflow, and you are responsible for parsing it according to the specification on the building workflows page.


const workflowId = await linkedapi.customWorkflow.execute({
  "actionType": "st.openPersonPage",
  "personUrl": "https://www.linkedin.com/in/john-doe"
  "basicInfo": true,
  "then": {
    "actionType": "st.checkConnectionStatus",
  }
});
      
const workflowCompletion = await linkedapi.customWorkflow.result(workflowId);

# 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/
    

Handling critical errors

Separate from the non-critical errors array returned by pre-defined workflows, the SDK can throw critical errors. These are exceptions that immediately stop execution and indicate a fundamental problem with the request or your account.

These exceptions, always of the type LinkedApiError, can be thrown when calling execute() to initiate a workflow or when calling result() to get the results. You must handle them using a try...catch block to inspect the error's type field and determine the cause.


try {
  const workflowId = await linkedapi.checkConnectionStatus.execute({
    personUrl: "https://www.linkedin.com/in/john-doe"
  });
  const { data, errors } = await linkedapi.checkConnectionStatus.result(workflowId);

  // 1. Handling non-critical execution errors
  if (errors && errors.length > 0) {
    console.warn('Workflow completed with execution errors:', errors);
  }

  // Handling the successful result
  if (data) {
    console.log('Connection Status:', data.connectionStatus);
  }

} catch (e) {
  // 2. Handling critical errors (exceptions)
  if (e instanceof LinkedApiError) {
    if (e.type === LINKED_API_ERROR.invalidLinkedApiToken) {
      console.error('Authentication failed. Please check your API token.');

    } else if (e.type === LINKED_API_ERROR.subscriptionRequired) {
      console.error('Invalid parameters in request:', e.message);
      
    } else {
      // Handle other types of critical API errors
      console.error(`A different API error occurred: ${e.type}`);
    }
  } else {
    // Handle other unexpected errors (e.g., network issues)
    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/
    

Here are all possible critical errors:

  • invalidLinkedApiToken – the provided linked-api-token is invalid.
  • invalidIdentificationToken – the provided identification-token is invalid.
  • subscriptionRequired – no purchased subscription seats available for this LinkedIn account.
  • plusPlanRequired – to execute this workflow you need the Plus plan.
  • invalidWorkflow (only for custom workflows) – workflow configuration is not valid due to violated action constraints or invalid action parameters: {validation_details}.
  • invalidRequestPayload – invalid request body/parameters: {validation_details}.
  • linkedinAccountSignedOut – your LinkedIn account has been signed out in our cloud browser. This occasionally happens as LinkedIn may sign out accounts after an extended period. You'll need to visit our platform and reconnect your account.
  • languageNotSupported – your LinkedIn account uses a language other than English, which is currently the only supported option. If you encounter this issue, please contact our support. We prioritize adding new languages based on user requests, so your feedback is important.