Search.../

bulkCreateDraftPosts( )

Developer Preview

Creates multiple draft posts.

Syntax

function bulkCreateDraftPosts(draftPosts: Array<DraftPost>, options: BulkCreateDraftPostsOptions): Promise<BulkCreateDraftPostsResponse>

bulkCreateDraftPosts Parameters

NAME
TYPE
DESCRIPTION
draftPosts
Array<
DraftPost
>

Draft posts to create.

options
Optional
BulkCreateDraftPostsOptions

Options for creating multiple draft posts.

Returns

Return Type:

Promise<
BulkCreateDraftPostsResponse
>
NAME
TYPE
DESCRIPTION
bulkActionMetadata
BulkActionMetadata

Bulk action metadata.

results
Array<
BulkDraftPostResult
>

Draft posts created by bulk action.

Was this helpful?

Bulk create draft posts (export from backend code)

Copy Code
1import { draftPosts } from 'wix-blog-backend';
2import { webMethod, Permissions } from 'wix-web-module';
3import { elevate } from 'wix-auth';
4
5const elevatedBulkCreateDraftPosts = elevate(draftPosts.bulkCreateDraftPosts)
6
7/* Sample draftPosts value:
8 * {
9 * "draftPosts": [
10 * "draftPost": {
11 * "categoryIds": [],
12 * "commentingEnabled": true,
13 * "featured": true,
14 * "language": "en",
15 * "media": {
16 * "custom": false,
17 * "displayed": true
18 * },
19 * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
20 * "previewTextParagraph": 2,
21 * "pricingPlanIds": [],
22 * "relatedPostIds": [],
23 * "richContent": {
24 * "nodes": [
25 * {
26 * "type": "PARAGRAPH",
27 * "id": "pvirv1",
28 * "nodes": [
29 * {
30 * "type": "TEXT",
31 * "id": "",
32 * "nodes": [],
33 * "textData": {
34 * "text": "Hello world",
35 * "decorations": []
36 * }
37 * }
38 * ],
39 * "paragraphData": {}
40 * }
41 * ],
42 * }
43 * "seoData": {
44 * "tags": []
45 * "},
46 * "seoSlug": "hello-world",
47 * "tagIds": [],
48 * "title": "Hello, world"
49 * },
50 * {
51 * "categoryIds": [],
52 * "commentingEnabled": true,
53 * "featured": true,
54 * "language": "en",
55 * "media": {
56 * "custom": false,
57 * "displayed": true
58 * },
59 * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
60 * "previewTextParagraph": 2,
61 * "pricingPlanIds": [],
62 * "relatedPostIds": [],
63 * "richContent": {
64 * "nodes": [
65 * {
66 * "type": "PARAGRAPH",
67 * "id": "pvirv1",
68 * "nodes": [
69 * {
70 * "type": "TEXT",
71 * "id": "",
72 * "nodes": [],
73 * "textData": {
74 * "text": "Hello to you too",
75 * "decorations": []
76 * }
77 * }
78 * ],
79 * "paragraphData": {}
80 * }
81 * ],
82 * }
83 * "seoData": {
84 * "tags": []
85 * "},
86 * "seoSlug": "hello-to-you-too",
87 * "tagIds": [],
88 * "title": "Hello to you too"
89 * },
90 * ]
91 * }
92 */
93
94export const myBulkCreateDraftPosts = webMethod(
95 Permissions.Anyone,
96 async (options) => {
97 try {
98 const draftPosts = await elevatedBulkCreateDraftPosts(options);
99 console.log('Created draft posts:', draftPosts)
100 return draftPosts;
101 } catch (error) {
102 console.error(error);
103 // Handle the error
104 }
105 }
106);
107
108/* Promise resolves to:
109 {
110 "bulkActionMetadada": {
111 "totalFailures": 0,
112 "totalSuccesses": 2,
113 "undetailedFailures": 0
114 },
115 "results": [
116 "item": {
117 "categoryIds": [],
118 "commentingEnabled": true,
119 "featured": true,
120 "language": "en",
121 "media": {
122 "custom": false,
123 "displayed": true
124 },
125 "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
126 "previewTextParagraph": 2,
127 "pricingPlanIds": [],
128 "relatedPostIds": [],
129 "richContent": {
130 "nodes": [
131 {
132 "type": "PARAGRAPH",
133 "id": "pvirv1",
134 "nodes": [
135 {
136 "type": "TEXT",
137 "id": "",
138 "nodes": [],
139 "textData": {
140 "text": "Hello world",
141 "decorations": []
142 }
143 }
144 ],
145 "paragraphData": {}
146 }
147 ],
148 }
149 "seoData": {
150 "tags": []
151 "},
152 "seoSlug": "hello-world",
153 "tagIds": [],
154 "title": "Hello, world"
155 },
156 "item": {
157 "categoryIds": [],
158 "commentingEnabled": true,
159 "featured": true,
160 "language": "en",
161 "media": {
162 "custom": false,
163 "displayed": true
164 },
165 "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
166 "previewTextParagraph": 2,
167 "pricingPlanIds": [],
168 "relatedPostIds": [],
169 "richContent": {
170 "nodes": [
171 {
172 "type": "PARAGRAPH",
173 "id": "pvirv1",
174 "nodes": [
175 {
176 "type": "TEXT",
177 "id": "",
178 "nodes": [],
179 "textData": {
180 "text": "Hello to you too",
181 "decorations": []
182 }
183 }
184 ],
185 "paragraphData": {}
186 }
187 ],
188 }
189 "seoData": {
190 "tags": []
191 "},
192 "seoSlug": "hello-to-you-too",
193 "tagIds": [],
194 "title": "Hello to you too"
195 }
196 ]
197 }
198 */
Bulk create draft posts

Copy Code
1import { draftPosts } from 'wix-blog-backend';
2
3/* Sample draftPosts value:
4 * {
5 * "draftPosts": [
6 * "draftPost": {
7 * "categoryIds": [],
8 * "commentingEnabled": true,
9 * "featured": true,
10 * "language": "en",
11 * "media": {
12 * "custom": false,
13 * "displayed": true
14 * },
15 * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
16 * "previewTextParagraph": 2,
17 * "pricingPlanIds": [],
18 * "relatedPostIds": [],
19 * "richContent": {
20 * "nodes": [
21 * {
22 * "type": "PARAGRAPH",
23 * "id": "pvirv1",
24 * "nodes": [
25 * {
26 * "type": "TEXT",
27 * "id": "",
28 * "nodes": [],
29 * "textData": {
30 * "text": "Hello world",
31 * "decorations": []
32 * }
33 * }
34 * ],
35 * "paragraphData": {}
36 * }
37 * ],
38 * }
39 * "seoData": {
40 * "tags": []
41 * "},
42 * "seoSlug": "hello-world",
43 * "tagIds": [],
44 * "title": "Hello, world"
45 * },
46 * {
47 * "categoryIds": [],
48 * "commentingEnabled": true,
49 * "featured": true,
50 * "language": "en",
51 * "media": {
52 * "custom": false,
53 * "displayed": true
54 * },
55 * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
56 * "previewTextParagraph": 2,
57 * "pricingPlanIds": [],
58 * "relatedPostIds": [],
59 * "richContent": {
60 * "nodes": [
61 * {
62 * "type": "PARAGRAPH",
63 * "id": "pvirv1",
64 * "nodes": [
65 * {
66 * "type": "TEXT",
67 * "id": "",
68 * "nodes": [],
69 * "textData": {
70 * "text": "Hello to you too",
71 * "decorations": []
72 * }
73 * }
74 * ],
75 * "paragraphData": {}
76 * }
77 * ],
78 * }
79 * "seoData": {
80 * "tags": []
81 * "},
82 * "seoSlug": "hello-to-you-too",
83 * "tagIds": [],
84 * "title": "Hello to you too"
85 * },
86 * ]
87 * }
88 */
89
90export async const myBulkCreateDraftPosts(options) => {
91 try {
92 const draftPosts = await draftPosts.bulkCreateDraftPosts(options);
93 console.log('Created draft posts:', draftPosts)
94 return draftPosts;
95 } catch (error) {
96 console.error(error);
97 // Handle the error
98 }
99 };
100
101/* Promise resolves to:
102 {
103 "bulkActionMetadada": {
104 "totalFailures": 0,
105 "totalSuccesses": 2,
106 "undetailedFailures": 0
107 },
108 "results": [
109 "item": {
110 "categoryIds": [],
111 "commentingEnabled": true,
112 "featured": true,
113 "language": "en",
114 "media": {
115 "custom": false,
116 "displayed": true
117 },
118 "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
119 "previewTextParagraph": 2,
120 "pricingPlanIds": [],
121 "relatedPostIds": [],
122 "richContent": {
123 "nodes": [
124 {
125 "type": "PARAGRAPH",
126 "id": "pvirv1",
127 "nodes": [
128 {
129 "type": "TEXT",
130 "id": "",
131 "nodes": [],
132 "textData": {
133 "text": "Hello world",
134 "decorations": []
135 }
136 }
137 ],
138 "paragraphData": {}
139 }
140 ],
141 }
142 "seoData": {
143 "tags": []
144 "},
145 "seoSlug": "hello-world",
146 "tagIds": [],
147 "title": "Hello, world"
148 },
149 "item": {
150 "categoryIds": [],
151 "commentingEnabled": true,
152 "featured": true,
153 "language": "en",
154 "media": {
155 "custom": false,
156 "displayed": true
157 },
158 "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
159 "previewTextParagraph": 2,
160 "pricingPlanIds": [],
161 "relatedPostIds": [],
162 "richContent": {
163 "nodes": [
164 {
165 "type": "PARAGRAPH",
166 "id": "pvirv1",
167 "nodes": [
168 {
169 "type": "TEXT",
170 "id": "",
171 "nodes": [],
172 "textData": {
173 "text": "Hello to you too",
174 "decorations": []
175 }
176 }
177 ],
178 "paragraphData": {}
179 }
180 ],
181 }
182 "seoData": {
183 "tags": []
184 "},
185 "seoSlug": "hello-to-you-too",
186 "tagIds": [],
187 "title": "Hello to you too"
188 }
189 ]
190 }
191 */