bulkCreateDraftPosts( )


Creates multiple draft posts.

Permissions
Manage Blog
Manage Members
Manage Bookings Services and Settings
Read Members and Contacts - all read permissions
Read Members
Manage Members and Contacts - all permissions
Learn more about app permissions.
Method Declaration
Copy
function bulkCreateDraftPosts(
  draftPosts: Array<DraftPost>,
  options: BulkCreateDraftPostsOptions,
): Promise<BulkCreateDraftPostsResponse>;
Method Parameters
draftPostsArray<DraftPost>Required

Draft posts to create.


optionsBulkCreateDraftPostsOptions

Options for creating multiple draft posts.

Returns
Return Type:Promise<BulkCreateDraftPostsResponse>
JavaScript
import { draftPosts } from "wix-blog-backend"; import { webMethod, Permissions } from "wix-web-module"; import { elevate } from "wix-auth"; const elevatedBulkCreateDraftPosts = elevate(draftPosts.bulkCreateDraftPosts); /* Sample draftPosts value: * { * "draftPosts": [ * "draftPost": { * "categoryIds": [], * "commentingEnabled": true, * "featured": true, * "language": "en", * "media": { * "custom": false, * "displayed": true * }, * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811", * "previewTextParagraph": 2, * "pricingPlanIds": [], * "relatedPostIds": [], * "richContent": { * "nodes": [ * { * "type": "PARAGRAPH", * "id": "pvirv1", * "nodes": [ * { * "type": "TEXT", * "id": "", * "nodes": [], * "textData": { * "text": "Hello world", * "decorations": [] * } * } * ], * "paragraphData": {} * } * ], * } * "seoData": { * "tags": [] * "}, * "seoSlug": "hello-world", * "tagIds": [], * "title": "Hello, world" * }, * { * "categoryIds": [], * "commentingEnabled": true, * "featured": true, * "language": "en", * "media": { * "custom": false, * "displayed": true * }, * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811", * "previewTextParagraph": 2, * "pricingPlanIds": [], * "relatedPostIds": [], * "richContent": { * "nodes": [ * { * "type": "PARAGRAPH", * "id": "pvirv1", * "nodes": [ * { * "type": "TEXT", * "id": "", * "nodes": [], * "textData": { * "text": "Hello to you too", * "decorations": [] * } * } * ], * "paragraphData": {} * } * ], * } * "seoData": { * "tags": [] * "}, * "seoSlug": "hello-to-you-too", * "tagIds": [], * "title": "Hello to you too" * }, * ] * } */ export const myBulkCreateDraftPosts = webMethod( Permissions.Anyone, async (options) => { try { const draftPosts = await elevatedBulkCreateDraftPosts(options); console.log("Created draft posts:", draftPosts); return draftPosts; } catch (error) { console.error(error); // Handle the error } }, ); /* Promise resolves to: { "bulkActionMetadada": { "totalFailures": 0, "totalSuccesses": 2, "undetailedFailures": 0 }, "results": [ "item": { "categoryIds": [], "commentingEnabled": true, "featured": true, "language": "en", "media": { "custom": false, "displayed": true }, "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811", "previewTextParagraph": 2, "pricingPlanIds": [], "relatedPostIds": [], "richContent": { "nodes": [ { "type": "PARAGRAPH", "id": "pvirv1", "nodes": [ { "type": "TEXT", "id": "", "nodes": [], "textData": { "text": "Hello world", "decorations": [] } } ], "paragraphData": {} } ], } "seoData": { "tags": [] "}, "seoSlug": "hello-world", "tagIds": [], "title": "Hello, world" }, "item": { "categoryIds": [], "commentingEnabled": true, "featured": true, "language": "en", "media": { "custom": false, "displayed": true }, "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811", "previewTextParagraph": 2, "pricingPlanIds": [], "relatedPostIds": [], "richContent": { "nodes": [ { "type": "PARAGRAPH", "id": "pvirv1", "nodes": [ { "type": "TEXT", "id": "", "nodes": [], "textData": { "text": "Hello to you too", "decorations": [] } } ], "paragraphData": {} } ], } "seoData": { "tags": [] "}, "seoSlug": "hello-to-you-too", "tagIds": [], "title": "Hello to you too" } ] } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?