Handling results and errors
When you initiate any workflow, the method immediately returns a WorkflowHandler
object. This object contains the workflowId
for tracking and the asynchronous result()
method, which resolves when the workflow is complete.
const workflowHandler = await linkedapi.checkConnectionStatus({
personUrl: "https://www.linkedin.com/in/john-doe"
});
const workflowId = workflowHandler.workflowId;
const result = await workflowHandler.result();
# 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.
const workflowHandler = await linkedapi.checkConnectionStatus({
personUrl: "https://www.linkedin.com/in/john-doe"
});
const result = await workflowHandler.result();
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/
data
object and a list of possible errors
are detailed on the corresponding page in the side navigation menu.For custom workflows
When using executeCustomWorkflow
, 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 workflowHandler = await linkedapi.executeCustomWorkflow({
"actionType": "st.openPersonPage",
"personUrl": "https://www.linkedin.com/in/john-doe"
"basicInfo": true,
"then": {
"actionType": "st.checkConnectionStatus",
}
});
const workflowCompletion = await workflowHandler.result();
# 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 initiating a workflow or calling handler.result()
. You must handle them using a try...catch
block to inspect the error's type
field and determine the cause.
try {
const workflowHandler = await linkedapi.checkConnectionStatus({
personUrl: "https://www.linkedin.com/in/john-doe"
});
const { data, errors } = await workflowHandler.result();
// 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 providedlinked-api-token
is invalid.invalidIdentificationToken
– the providedidentification-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 us atsupport@linkedapi.io
. We prioritize adding new languages based on user requests, so your feedback is important.