Get Draft Post (REST API): can't get Rich Content (400 Bad Request)

Question:
Getting a draft blog post’s rich content (richContent) doesn’t work.

Product:
Wix REST API / GetDraftPost endpoint

What are you trying to achieve:
I need to retrieve the rich content of a draft blog post so I can then modify it and update my website programmatically.

One of the rich content treatment processes will be to move the draft blog post’s content to a dedicated Wix Dynamic Page. Since a blog’s content is of the same type as a collection’s “rich content” column, it should be easy to export a draft blog post’s rich content and import it in a collection.

I’m creating an Educational Resources section on my website that will include educational guides using Dynamic Pages (1 guide = 1 dynamic page = 1 item in a GUIDE collection in the CMS). I don’t want these guides to be blog posts: I want more freedom in terms of layouts, navigation and table of contents. That will be achieved with custom layouts for the Guide template dynamic page.

I will also want to programmatically process each draft blog post’s so a manual solution is not an option.

What have you already tried:

I’ve used the “Try it out” button. I can connect with my account, site ID, provide a draft blog post ID, send the request, get an HTTP 200 response… I can check the fieldsets query param and set it to “URL” (without quote marks)… Fine.

BUT if I change the value of fieldsets to “richContent” or “RICHCONTENT”, I get an HTTP 400 Bad Request response.

Response Body

{

“message”: “Failed to parse JSON or deserialize protobuf message”,

“details”: {}

}
image

Additional information:
The documentation for the GetDraftPost endpoint only contains 1 example for the fieldset query parameter: URL. What if you want a different field than URL? Where’s the list of fields that can be accessed?

Hello! From the documentation, richContent should re returned in the base fields and is not a fieldset. Are you getting back the richContent as part of your response when you do not include the fieldset?

If that does not work, I would suggest heading to our Devs On Wix Discord server and posting your question in the headless channel.

@amandam thanks for your reply.

richContent is absolutely not returned by default in the base fields. It’s actually very weird that we don’t get the draft post content when we GetDraftPost… but only base fields like title, language, seoData…

Here are the fields I get (I replaced all real values by “…” for privacy):

JSON:

{
  "draftPost": {
    "id": "[...]",
    "title": "[...]",
    "excerpt": "[...]",
    "featured": [...],
    "categoryIds": [
      "[...]",
      "[...]"
    ],
    "coverMedia": {
      "enabled": [...],
      "image": {
        "id": "[...]",
        "url": "[...]",
        "height": [...],
        "width": [...]
      },
      "displayed": [...],
      "custom": [...]
    },
    "memberId": "[...]",
    "hashtags": [...],
    "commentingEnabled": [...],
    "minutesToRead": [...],
    "tagIds": [...],
    "relatedPostIds": [
      "[...]",
      "[...]"
    ],
    "pricingPlanIds": [...],
    "language": "[...]",
    "changeOrigin": "[...]",
    "contentId": "[...]",
    "editingSessionId": "[...]",
    "status": "[...]",
    "mostRecentContributorId": "[...]",
    "hasUnpublishedChanges": [...],
    "editedDate": "[...]",
    "firstPublishedDate": "[...]",
    "seoData": {
      "tags": [
        {
          "type": "[...]",
          "props": {
            "name": "[...]",
            "content": "[...]"
          },
          "children": "[...]",
          "custom": [...],
          "disabled": [...]
        }
      ],
      "settings": {
        "preventAutoRedirect": [...],
        "keywords": [
          {
            "term": "[...]",
            "isMain": [...]
          }
        ]
      }
    },
    "slugs": [...],
    "createdDate": "[...]",
    "seoSlug": "[...]",
    "media": {
      "wixMedia": {
        "image": {
          "id": "[...]",
          "url": "[...]",
          "height": [...],
          "width": [...]
        }
      },
      "displayed": [...],
      "custom": [...]
    },
    "translations": [...]
  }
}

also, I discovered after many trials that you need to request field RICH_CONTENT (case sensitive) in order for the response to contain the richContent field. This is mentioned nowhere in the documentation. The only fieldset field name mentioned is the “URL” example so Wix API users have to guess each field name.

Finally, I’m having a huge issue out of nowhere:

  • I’ve been writing a 5000+ word blog post in Wix blog for weeks
  • Now when I try to edit it in Wix Blog draft post editor, it starts loading the article, I see the title for half a second, then it disappears and I get this error message “We’re having a technical issue. Please refresh the page and retry”.

I’ve refreshed many times: no change. I’ve tried clearing my cache, accessing it through Chrome’s Private Browsing mode… no way to load the article. I’ve opened other articles, both draft and published: no issue at all. It’s only this post, which I managed to edit just fine over the past few days.

This is dozens of hours of work… GONE.

Please note that I have only created and modified this draft post in the Wix blog UI. It hasn’t been created or updated via the API. My previous question regarding GetDraftPost was only to extract the richContent, not update it in Wix.

Please get Wix’s tech staff to look into this. I’m sure the post’s content is still there but there in the database but there’s some kind of rendering issue.

Draft post ID: 732f1eb6-a41e-477c-9de7-85bf12c93670
Account ID: 91e6f983-6dc8-4eb4-aaee-f1dbf9fc8d0d

Please help. This is business critical for me. We’re a small business that needs this content to get out ASAP.

Hello! I’m glad you figured out how to leverage the rich content field, I will add some feedback that the docs are not clear in this case.

As for your other issue, if you have not already you will want to reach out to Customer Care to create a ticket for investigation. This type of issue isn’t something we will be able to resolve here unfortunately.

Hello Amanda. Thanks. I’ve reached out to customer support yesterday with details about the issue. I really hope they’ll recover my 5000 word draft blog post…

1 Like