Retrieve the draft (unpublished) version of a blog post.
1
//native
2
3
/**
4
* Get Blog Post Draft
5
* Retrieve the draft (unpublished) version of a blog post. Requires the content scope.
6
*/
7
export async function main(auth: RT.Hubspot, blog_post_id: string) {
8
const url = new URL(
9
`https://api.hubapi.com/cms/v3/blogs/posts/${blog_post_id}/draft`
10
)
11
12
const response = await fetch(url, {
13
headers: {
14
Authorization: `Bearer ${auth.token}`,
15
Accept: "application/json",
16
},
17
})
18
19
if (!response.ok) {
20
throw new Error(`${response.status} ${await response.text()}`)
21
}
22
23
return await response.json()
24
25