Publish BlogPost via API

Have anyone published a blog post from the API? I can create it but it refuses to be published. So I have to go into the portal and publish it manually.
Here is my code:

const post = new BlogPost()
// ... filling with content etc
post.currentState = 'PUBLISHED'
post.publishImmediately = true
post.publishDate = new Date

const blogPost = await hubspot.cms.blogs.blogPosts.blogPostsApi.create(post)
await hubspot.cms.blogs.blogPosts.blogPostsApi.pushLive(blogPost.id)

Hello @ajinvise , Happy Mondat!

Are you using a V3 endpoint? There are a few requirements that this developers document with more details on how to publish a blog post here.

I hope this information helps.

Pam

Hi @PamCotton !
Thank you, I am using that exact page to guide me and still fail. So I am using the official client which is using v3. Do you know a developer we can ask to take a look?
Below is a somewhat more complete example of my code:

 const post = new BlogPost()
 post.contentGroupId = config.BLOG_ID
 post.name = details.Release.Title
 post.slug = details.Release.Title
 post.metaDescription = details.Release.Title
 post.tagIds = tagIds
 post.postBody = details.Release.HtmlBody.replace(
 /(<[^>]*) style=("[^"]+"|'[^']+')([^>]*>)/gi,
 '$1$3'
 );
 post.postSummary
 post.featuredImage = details.Release.Images[0].DownloadUrl
 post.blogAuthorId = config.BLOG_AUTHOR_ID
 post.currentState = 'PUBLISHED'
 post.publishImmediately = true
 post.publishDate = new Date

 post.widgets = {
 post_settings: {
 press_data: {
 ...trimmedDetails,
 }
 }
 }
 // Successful
 const blogPost = await hubspot.cms.blogs.blogPosts.blogPostsApi.create(post)

 // Successful but the post is not published
 // It is weird because it can be publish via portal no problem.
 await hubspot.cms.blogs.blogPosts.blogPostsApi.pushLive(blogPost.id)

Hi!

I had the exact same issue. For me it was the property state that did the trick. When I passed State: ‘PUBLISHED’ it worked. Did not use the pushLive function.

/Mats