Skip to content

Instantly share code, notes, and snippets.

@Khaledgarbaya
Created June 9, 2020 07:27
Show Gist options
  • Save Khaledgarbaya/fb0957ffe0e68bda4b549f56e95960db to your computer and use it in GitHub Desktop.
Save Khaledgarbaya/fb0957ffe0e68bda4b549f56e95960db to your computer and use it in GitHub Desktop.
Contentful management raw request example
// Get Scheduled actions
const contentful = require('contentful-management')
const spaceId = 'enter-your-space-id-here'
const accessToken = 'enter-your-access-token-here'
const envId = 'master'
const entryId = 'enter-entry-id-here'
const client = contentful.createClient({
accessToken: accessToken
})
// Get a scheduled action for an entry
client.rawRequest({
method: 'GET',
url: `${spaceId}/scheduled_actions?entity.sys.id=${entryId}&environment.sys.id=${envId}`
})
.then((responseData) => console.log(responseData))
// Create a scheduled action for an entry
client.rawRequest({
method: 'POST',
url: `${spaceId}/scheduled_actions`,
data: {
"entity": {
"sys": {
"type": "Link",
"linkType": "Entry",
"id": `${entryId}`
}
},
"environment": {
"sys": {
"type": "Link",
"linkType": "Environment",
"id": `${envId}`
}
},
"scheduledFor": {
"datetime": "2119-09-02T14:00:00.000Z"
},
"action": "publish"
}
})
.then((responseData) => console.log(responseData))
.catch(console.error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment