Create new entry failing
See original GitHub issueWhen creating an new entry as per guidelines https://contentful.github.io/contentful-management.js/contentful-management/3.3.4/typedef/index.html#static-typedef-Entry I get the following error: (getting the space works correctly - this error happens when invoking space.createEntry({})
.
{ BadRequest: {
"status": 400,
"statusText": "Bad Request",
"message": "Missing object",
"details": {},
"request": {
"url": "https://api.contentful.com:443/spaces/myspace/entries",
"headers": {
"Accept": "application/json, text/plain, */*",
"Content-Type": "application/vnd.contentful.management.v1+json",
"X-Contentful-User-Agent": "contentful-management.js/3.3.4",
"Authorization": "Bearer ACCESS_TOKEN",
"user-agent": "node.js/v6.10.0",
"Accept-Encoding": "gzip",
"X-Contentful-Content-Type": {}
},
"method": "post"
},
"requestId": "removedforissue"
}
If I put content into body
space.createEntry({
fields: {
title: {'en-AU': slugThisMonth},
body: {
file: {'en-AU': pdfAssetId},
effectiveDate: {'en-AU': new Date().toISOString()},
name: {'en-AU': slugThisMonth}
}
},
})
I get the following error (much the same, just with the extra body)
{ BadRequest: {
"status": 400,
"statusText": "Bad Request",
"message": "Missing object",
"details": {},
"request": {
"url": "https://api.contentful.com:443/spaces/myspace/entries",
"headers": {
"Accept": "application/json, text/plain, */*",
"Content-Type": "application/vnd.contentful.management.v1+json",
"X-Contentful-User-Agent": "contentful-management.js/3.3.4",
"Authorization": "Bearer ACCESS_TOKEN",
"user-agent": "node.js/v6.10.0",
"Accept-Encoding": "gzip",
"X-Contentful-Content-Type": {
"fields": {
"title": {
"en-AU": "cf-April-2017"
},
"body": {
"file": {
"en-AU": "afileid"
},
"effectiveDate": {
"en-AU": "2017-04-05T04:09:55.461Z"
},
"name": {
"en-AU": "cf-April-2017"
}
}
}
}
},
"method": "post"
},
"requestId": "removedforissue"
}
Following the documentation at https://www.contentful.com/developers/docs/references/content-management-api/#/reference/entries leads to the same path.
I do have content types setup, in my space, and can’t determine how to create an entry within a content type - maybe this is what i’m missing?
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Java - How to create new Entry (key, value) - Stack Overflow
I'd like to create new item that similarly to Util. Map. Entry that will contain the structure key , value . The problem...
Read more >Solved: Failed to create a new item - Canvas Community
Solved: Hi! There are instances when I try to upload an item in the module, a pink dialog box appears saying "Failed to...
Read more >Failed to Create New Entry for an Issue Because Conflicting ...
Cause. More than one row in the AO_60DB71_ISSUERANKING table exists for the custom field YYYYY, which is pointing to the issue XXXXX.
Read more >create new record failed | Support Center
Hi, while creating a new record i'm getting error saying create new record failed: pxCreateRecord api failed.
Read more >Action 'Create item' failed (Flow cannot create it...
Please check if you have filled proper value within fields of "Create item" action. Also please check if the data type of dynamic...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ohh sorry, I overlooked that:
The first parameter of
space.createEntry()
is the content type as string, the second is your actual entry data.Also, you need to create an asset first before you can attach it to the entry. (At least if you want to be present in the entry in the moment when the entry is created)
In total, it might later look like this:
Cheers, Benedikt
Hi, my comment is a bit outdated) I faced with same error and found that we need to pass 2 arguments to
createEntry
- first one is content type id and second one is entry itself.I use
"contentful-management": "^10.6.3"
Example:
space.createEntry('contentTypeId', { fields: { ... } })
In the example above you can see that entry JSON was added to “X-Contentful-Content-Type” header:
"X-Contentful-Content-Type": { "fields": { "title": { "en-AU": "cf-April-2017" }, ... } }
But this header is responsible for content type, as per Contentful API examples (saw in Contentful trainig video).