wordpress-to-contentful icon indicating copy to clipboard operation
wordpress-to-contentful copied to clipboard

Validation error on RichText fields

Open Ortimis opened this issue 5 years ago • 2 comments

Thank you for sharing your script, it works like a charm! However I stumbled upon an validation error with RichText fields when uploading posts to contentful which I could not solve and for which I am unable to find any documentation of. Maybe someone knows more?

(The value of the body and excerpt are in all cases not simple strings as in this example but transformed markdown from wordpress posts from the output of this script) Thank you!

("node":30500) UnhandledPromiseRejectionWarning:"InvalidEntry":{
   "status":422,
   "statusText":"Unprocessable Entity",
   "message":"Validation error",
   "details":{
      "errors":[
         {
            "name":"type",
            "value":"Here is the body of the Blogpost",
            "type":"RichText",
            "details":"The type of \"value\" is incorrect, expected type: RichText",
            "path":[
               "fields",
               "body",
               "en-US"
            ]
         },
         {
            "name":"type",
            "value":"This is the Blog post excerpt",
            "type":"RichText",
            "details":"The type of \"value\" is incorrect, expected type: RichText",
            "path":[
               "fields",
               "description",
               "en-US"
            ]
         }
      ]
   },
   "request":{
      "url":"entries",
      "headers":{
         "Accept":"application/json, text/plain, */*",
         "Content-Type":"application/vnd.contentful.management.v1+json",
         "X-Contentful-User-Agent":"sdk contentful-management.js/5.28.0; platform node.js/v12.18.3; os Windows/10.0.17763;",
         "Authorization":"Bearer ...wIpJw",
         "user-agent":"node.js/v12.18.3",
         "Accept-Encoding":"gzip",
         "X-Contentful-Content-Type":"blogPost",
         "Content-Length":5026
      },
      "method":"post",
      "payloadData":"{\"fields\":{\"title\":{\"de\":\"Interview zu Kleinstunternehmen in Wirtschaftswissenschaften und -ethik\"},\"body\":{\"de\":\"Here is the body of the Blogpost"},\"description\":{\"de\":\"This is the Blog post excerpt"},\"slug\":{\"de\":\"interview-zu-kleinstunternehmen-in-wirtschaftswissenschaften-und-ethik\"},\"publishDate\":{\"de\":\"2018-10-07T12:59:06+00:00\"},\"heroImage\":{\"de\":{\"sys\":{\"type\":\"Link\",\"linkType\":\"Asset\",\"id\":\"64sKvWtGm6c1zjtgeJadku\"}}},\"author\":{\"de\":{\"sys\":{\"type\":\"Link\",\"linkType\":\"Entry\",\"id\":\"12\"}}}}}"
   },

Ortimis avatar Sep 04 '20 21:09 Ortimis

Thanks for the detailed issue, @Ortimis. I haven't worked with the RichText field type much, but this would definitely be a useful addition. I will take a look next chance I get. If you've already found a workaround, feel free to open a PR!

xdmorgan avatar Oct 24 '20 00:10 xdmorgan

@Ortimis Contenful provides a markdown to rich text npm package to create the nodeTypes needed for the Rich Text content type. I also realize this is years old but posting for others in case it's needed.

https://www.npmjs.com/package/@contentful/rich-text-from-markdown

ChrisSki avatar May 23 '22 16:05 ChrisSki