//native
/**
* Schedule Blog Post
* Schedule a blog post to be published at a given time (ISO 8601). Requires the content scope.
*/
export async function main(
auth: RT.Hubspot,
blog_post_id: string,
publish_date: string
) {
const url = new URL(`https://api.hubapi.com/cms/v3/blogs/posts/schedule`)
const body: { [key: string]: any } = {}
body.id = blog_post_id
body.publishDate = publish_date
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${auth.token}`,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify(body),
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
if (response.status === 204) return { success: true }
return await response.json()
}
Submitted by hugo989 5 hours ago