acceptInvitation
This method accepts an incoming invitation by type and target URL.
typescript
try {
const workflow = await linkedapi.acceptInvitation.execute({
invitationType: "connect",
personUrl: "https://www.linkedin.com/in/john-doe",
});
const { errors } = await linkedapi.acceptInvitation.result(
workflow.workflowId,
);
// The list of possible execution errors is below
if (errors && errors.length > 0) {
console.warn("Workflow completed with execution errors:");
for (const error of errors) {
console.warn(` - Type: ${error.type}, Message: ${error.message}`);
}
} else {
console.log("Invitation accepted successfully.");
}
} 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);
}
}Params
invitationType– required invitation type:connect,companyFollow, ornewsletterSubscribe.personUrl– required only forconnect.companyUrl– required only forcompanyFollow.newsletterUrl– required only fornewsletterSubscribe.
Provide exactly one URL matching invitationType.
Data
The method doesn't return any data.
Errors
noPendingRequest– there is no matching pending invitation for the supplied type and URL.