Skip to content

Commit 7e68cee

Browse files
authored
[BUG] 403 error when trying to create a simple text post in LinkedIn (#17829)
1 parent b0e413e commit 7e68cee

File tree

21 files changed

+78
-52
lines changed

21 files changed

+78
-52
lines changed

components/linkedin/actions/create-comment/create-comment.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "linkedin-create-comment",
55
name: "Create Comment",
66
description: "Create a comment on a share or user generated content post. [See the docs here](https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/network-update-social-actions#create-comment)",
7-
version: "0.1.7",
7+
version: "0.1.8",
88
type: "action",
99
props: {
1010
linkedin,

components/linkedin/actions/create-image-post-organization/create-image-post-organization.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "linkedin-create-image-post-organization",
88
name: "Create Image Post (Organization)",
99
description: "Create an image post on LinkedIn. [See the documentation](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/images-api?view=li-lms-2023-09&tabs=http#uploading-an-image)",
10-
version: "1.0.2",
10+
version: "1.0.3",
1111
type: "action",
1212
props: {
1313
linkedin,
@@ -87,7 +87,11 @@ export default {
8787

8888
await this.linkedin.createPost({
8989
data: {
90-
author: this.organizationId,
90+
author: `urn:li:organization:${this.organizationId}`,
91+
lifecycleState: "PUBLISHED",
92+
distribution: {
93+
feedDistribution: "MAIN_FEED",
94+
},
9195
commentary: utils.escapeText(this.text),
9296
visibility: "PUBLIC",
9397
content: {

components/linkedin/actions/create-image-post-user/create-image-post-user.mjs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "linkedin-create-image-post-user",
88
name: "Create Image Post (User)",
99
description: "Create an image post on LinkedIn. [See the documentation](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/images-api?view=li-lms-2023-09&tabs=http#uploading-an-image)",
10-
version: "1.0.2",
10+
version: "1.0.3",
1111
type: "action",
1212
props: {
1313
linkedin,
@@ -85,8 +85,17 @@ export default {
8585

8686
await this.uploadImage(uploadUrl, formData);
8787

88+
const { id } = await this.linkedin.getCurrentMemberProfile({
89+
$,
90+
});
91+
8892
await this.linkedin.createPost({
8993
data: {
94+
author: `urn:li:person:${id}`,
95+
lifecycleState: "PUBLISHED",
96+
distribution: {
97+
feedDistribution: "MAIN_FEED",
98+
},
9099
commentary: utils.escapeText(this.text),
91100
visibility: this.visibility,
92101
content: {

components/linkedin/actions/create-like-on-share/create-like-on-share.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "linkedin-create-like-on-share",
55
name: "Create Like On Share",
66
description: "Creates a like on a share. [See the docs here](https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/network-update-social-actions#create-a-like-on-a-share)",
7-
version: "0.1.7",
7+
version: "0.1.8",
88
type: "action",
99
props: {
1010
linkedin,

components/linkedin/actions/create-text-post-organization/create-text-post-organization.mjs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "linkedin-create-text-post-organization",
66
name: "Create a Simple Post (Organization)",
77
description: "Create post on LinkedIn using text, URL or article. [See the documentation](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/posts-api?view=li-lms-2022-11&tabs=http#create-organic-posts) for more information",
8-
version: "0.0.7",
8+
version: "0.0.8",
99
type: "action",
1010
props: {
1111
linkedin,
@@ -30,9 +30,13 @@ export default {
3030
},
3131
async run({ $ }) {
3232
const data = {
33-
author: this.organizationId,
33+
author: `urn:li:organization:${this.organizationId}`,
3434
commentary: utils.escapeText(this.text),
3535
visibility: "PUBLIC",
36+
lifecycleState: "PUBLISHED",
37+
distribution: {
38+
feedDistribution: "MAIN_FEED",
39+
},
3640
};
3741
if (this.article) {
3842
data.content = {
@@ -47,6 +51,8 @@ export default {
4751
data,
4852
});
4953
$.export("$summary", "Successfully created a new Post as Organization");
50-
return response;
54+
return response || {
55+
success: true,
56+
};
5157
},
5258
};

components/linkedin/actions/create-text-post-user/create-text-post-user.mjs

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "linkedin-create-text-post-user",
66
name: "Create a Simple Post (User)",
77
description: "Create post on LinkedIn using text, URL or article. [See the documentation](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/posts-api?view=li-lms-2022-11&tabs=http#create-organic-posts) for more information",
8-
version: "0.0.7",
8+
version: "0.0.8",
99
type: "action",
1010
props: {
1111
linkedin,
@@ -29,23 +29,43 @@ export default {
2929
},
3030
},
3131
async run({ $ }) {
32-
const data = {
33-
commentary: utils.escapeText(this.text),
34-
visibility: this.visibility,
35-
};
36-
if (this.article) {
37-
data.content = {
38-
article: {
39-
source: this.article,
40-
title: this.article,
41-
},
42-
};
43-
}
44-
const response = await this.linkedin.createPost({
32+
const {
33+
linkedin,
34+
visibility,
35+
text,
36+
article,
37+
} = this;
38+
39+
const profile = await linkedin.getCurrentMemberProfile({
40+
$,
41+
});
42+
43+
const response = await linkedin.createPost({
4544
$,
46-
data,
45+
data: {
46+
author: `urn:li:person:${profile?.id}`,
47+
lifecycleState: "PUBLISHED",
48+
distribution: {
49+
feedDistribution: "MAIN_FEED",
50+
},
51+
commentary: utils.escapeText(text),
52+
visibility,
53+
...(article
54+
? {
55+
content: {
56+
article: {
57+
source: article,
58+
title: article,
59+
},
60+
},
61+
}
62+
: {}
63+
),
64+
},
4765
});
4866
$.export("$summary", "Successfully created a new Post as User");
49-
return response;
67+
return response || {
68+
success: true,
69+
};
5070
},
5171
};

components/linkedin/actions/delete-post/delete-post.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "linkedin-delete-post",
55
name: "Delete Post",
66
description: "Removes a post from user's wall. [See the docs](https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/share-api?tabs=http#delete-shares) for more information",
7-
version: "0.0.7",
7+
version: "0.0.8",
88
type: "action",
99
props: {
1010
linkedin,

components/linkedin/actions/fetch-ad-account/fetch-ad-account.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "linkedin-fetch-ad-account",
55
name: "Fetch Ad Account",
66
description: "Fetches an individual adAccount given its id. [See the docs here](https://docs.microsoft.com/en-us/linkedin/marketing/integrations/ads/account-structure/create-and-manage-accounts#fetch-ad-account)",
7-
version: "0.1.7",
7+
version: "0.1.8",
88
type: "action",
99
props: {
1010
linkedin,

components/linkedin/actions/get-current-member-profile/get-current-member-profile.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "linkedin-get-current-member-profile",
55
name: "Get Current Member Profile",
66
description: "Gets the profile of the current authenticated member. [See the docs here](https://docs.microsoft.com/en-us/linkedin/shared/integrations/people/profile-api#retrieve-current-members-profile)",
7-
version: "0.1.7",
7+
version: "0.1.8",
88
type: "action",
99
props: {
1010
linkedin,

components/linkedin/actions/get-member-profile/get-member-profile.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "linkedin-get-member-profile",
55
name: "Get Member Profile",
66
description: "Gets another member's profile, given its person id. [See the docs here](https://docs.microsoft.com/en-us/linkedin/shared/integrations/people/profile-api#retrieve-other-members-profile)",
7-
version: "0.1.7",
7+
version: "0.1.8",
88
type: "action",
99
props: {
1010
linkedin,

0 commit comments

Comments
 (0)