Created
June 9, 2020 07:27
-
-
Save Khaledgarbaya/fb0957ffe0e68bda4b549f56e95960db to your computer and use it in GitHub Desktop.
Contentful management raw request example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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