Skip to content

Instantly share code, notes, and snippets.

@weienwong
Created November 14, 2019 22:43
Show Gist options
  • Save weienwong/83ef5cc50eb206afd338c458e310e330 to your computer and use it in GitHub Desktop.
Save weienwong/83ef5cc50eb206afd338c458e310e330 to your computer and use it in GitHub Desktop.
async function publishItem (instanceZUID, modelZUID, itemZUID, version) {
const options = {
method: 'POST',
hostname: `${instanceZUID}.api.zesty.io`,
path: `/v1/content/models/${modelZUID}/items/${itemZUID}/publishings`,
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${DEV_TOKEN}`
}
}
const req = https.request(options, function (res) {
const chunks = []
res.on('data', function (chunk) {
chunks.push(chunk)
})
res.on('end', function (chunk) {
const body = Buffer.concat(chunks)
console.log(body.toString())
})
res.on('error', function (error) {
console.error(error)
})
})
const postData = {
version: version,
publishAt: 'now',
unpublishAt: '2019-12-31'
}
req.write(JSON.stringify(postData))
req.end()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment