> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: updateDraftPost(_id: string, draftPost: UpdateDraftPost, options: UpdateDraftPostOptions) # Method package: wixBlogBackend # Method menu location: wixBlogBackend --> draftPosts --> updateDraftPost # Method Link: https://dev.wix.com/docs/velo/apis/wix-blog-backend/draft-posts/update-draft-post.md # Method Description: Updates a draft post. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Update a draft post (export from backend code) ```javascript import { draftPosts } from 'wix-blog-backend'; import { webMethod, Permissions } from 'wix-web-module'; /* Sample id value: "c4696594-b02e-4d24-afc1-97da073783b4" * * Sample draftPost value: * { * "categoryIds": [], * "commentingEnabled": true, * "editingSessionId": "5e9c24a9-6318-4ca7-9df5-0d9a6a10d3ee", * "excerpt": "When we start, we start from the beginning.", * "featured": false, * "hashtags": [], * "language": "en", * "media": { * "custom": false, * "displayed": true * }, * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811", * "paidContentParagraph": 4, * "pricingPlanIds": [], * "relatedPostIds": [ * "c4696594-b02e-4d24-afc1-97da073783b4", * "66935097-31c5-4fab-9693-aa1b53aeea77" * ], * "seoData": { * "tags": [] * }, * "tagIds": [], * "title": "How to make friends and influence people.", * "translations": [] * } */ export const myUpdateDraftPostFunction = webMethod( Permissions.Admin, async (id, draftPost) => { try { const updatedDraftPost = await draftPosts.updateDraftPost(id, draftPost); console.log('Successfully updated the following draft post":', updatedDraftPost); return updatedDraftPost; } catch (error) { console.error(error); // Handle the error } } ); /* Promise resolves to: * { * "categoryIds": [], * "commentingEnabled": true, * "editingSessionId": "5e9c24a9-6318-4ca7-9df5-0d9a6a10d3ee", * "excerpt": "When we start, we start from the beginning.", * "featured": false, * "hashtags": [], * "language": "en", * "media": { * "custom": false, * "displayed": true * }, * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811", * "paidContentParagraph": 4, * "pricingPlanIds": [], * "relatedPostIds": [ * "c4696594-b02e-4d24-afc1-97da073783b4", * "66935097-31c5-4fab-9693-aa1b53aeea77" * ], * "seoData": { * "tags": [] * }, * "tagIds": [], * "title": "How to make friends and influence people.", * "translations": [] * } */ ``` ## Update a draft post using options (export from backend code) ```javascript // This example updates the draft and publishes it import { draftPosts } from 'wix-blog-backend'; import { webMethod, Permissions } from 'wix-web-module'; /* Sample id value = "c8d50953-b31c-435f-82ec-a53d8bff87b4" * * Sample draftPost value: * { * "categoryIds": [], * "commentingEnabled": true, * "excerpt": "If it wasn't for grit, we wouldn't succeed.", * "featured": false, * "hashtags": [ * "vacation", * "dream", * "summer", * ], * "language": "en", * "media": { * "custom": false, * "displayed": true * }, * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811", * "paidContentParagraph": 4, * "pricingPlanIds": [], * "relatedPostIds": [], * "seoData": { * tags": [] * }, * "tagIds": [], * "title": "Grit is the special sauce.", * "translations": [] * }; * * Sample options value": * { * "action": "UPDATE_PUBLISH", * "fieldsets": "GENERATED_EXCERPT", * "scheduledPublishDate": new Date("2024-08-09T15:30:00Z") * } */ export const myUpdateDraftPostFunction = webMethod( Permissions.Admin, async (id, draftPost, options) => { try { const updatedDraftPost = await draftPosts.updateDraftPost(id, draftPost, options); console.log('Successfully updated the following draft post":', updatedDraftPost); return updatedDraftPost; } catch (error) { console.error(error); // Handle the error } } ); /* Promise resolves to: * { * "categoryIds": [], * "commentingEnabled": true, * "excerpt": "If it wasn't for grit, we wouldn't succeed.", * "featured": false, * "hashtags": [ * "vacation", * "dream", * "summer" * ], * "language": "en", * "media": { * "custom": false, * "displayed": true * }, * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811", * "paidContentParagraph": 4, * "pricingPlanIds": [], * "relatedPostIds": [], * "seoData": { * "tags": [] * }, * "tagIds": [], * "title": "Grit is the special sauce." * } */ ``` ## Update a draft post ```javascript import { draftPosts } from 'wix-blog-backend'; /* Sample id value: "c4696594-b02e-4d24-afc1-97da073783b4" * * Sample draftPost value: * { * categoryIds: [], * commentingEnabled: true, * editingSessionId: "5e9c24a9-6318-4ca7-9df5-0d9a6a10d3ee", * excerpt: "When we start, we start from the beginning.", * featured: false, * hashtags: [], * language: "en", * media: { * custom: false, * displayed: true * }, * memberId: "c00e8a5c-322b-4e77-8813-002e3ea7e811", * paidContentParagraph: 4, * pricingPlanIds: [], * relatedPostIds: [ * "c4696594-b02e-4d24-afc1-97da073783b4", * "66935097-31c5-4fab-9693-aa1b53aeea77" * ], * seoData: { * tags: [] * }, * tagIds: [], * title: "How to make friends and influence people.", * translations: [] * } */ export async function myUpdateDraftPostFunction(id, draftPost) { try { const updatedDraftPost = await draftPosts.updateDraftPost(id, draftPost); console.log('Successfully updated the following draft post:', updatedDraftPost); return updatedDraftPost; } catch (error) { console.error(error); // Handle the error } } ); /* Promise resolves to: * { * "categoryIds": [], * "commentingEnabled": true, * "editingSessionId": "5e9c24a9-6318-4ca7-9df5-0d9a6a10d3ee", * "excerpt": "When we start, we start from the beginning.", * "featured": false, * "hashtags": [], * "language": "en", * "media": { * "custom": false, * "displayed": true * }, * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811", * "paidContentParagraph": 4, * "pricingPlanIds": [], * "relatedPostIds": [ * "c4696594-b02e-4d24-afc1-97da073783b4", * "66935097-31c5-4fab-9693-aa1b53aeea77" * ], * "seoData": { * "tags": [] * }, * "tagIds": [], * "title": "How to make friends and influence people.", * "translations": [] * } */ ``` ---