Update a blog post directly.
1
//native
2
3
/**
4
* Update Blog Post
5
* Update a blog post directly. On a published post this changes the live version immediately; use Update Blog Post Draft to stage changes instead. Requires the content scope.
6
*/
7
export async function main(
8
auth: RT.Hubspot,
9
blog_post_id: string,
10
body: { [key: string]: any }
11
) {
12
const url = new URL(
13
`https://api.hubapi.com/cms/v3/blogs/posts/${blog_post_id}`
14
)
15
16
const response = await fetch(url, {
17
method: "PATCH",
18
headers: {
19
Authorization: `Bearer ${auth.token}`,
20
"Content-Type": "application/json",
21
Accept: "application/json",
22
},
23
body: JSON.stringify(body),
24
})
25
26
if (!response.ok) {
27
throw new Error(`${response.status} ${await response.text()}`)
28
}
29
30
return await response.json()
31
32