Trouble Incorporating Images in Blog Draft via REST API: Seeking Guidance

Product: Wix REST API

I aim to seamlessly upload a blog post to my Wix website using the REST API, including titles, SEO data, headlines, text, paragraphs, and images.

I’ve tried the following:

  • Uploading various components like titles, SEO data, headlines, and texts, which have all been successful.
  • Including the image details within the richContent object in different manners.
  • Checking for the uploaded images in the Wix GUI blog draft after receiving a 200 response.
  • Working with the heroImage object, but facing similar issues.

Even though I get a positive 200 response after my API calls, the images are not visible in the Wix GUI blog draft. I’m particularly stumped since other components like texts and headlines appear correctly.

Heres an example of my attempt JSON request

{
  "draftPost": {
    "title": "This is the blog template title 3",
    "memberId": "476f91b6-8e98-4b0c-bee0-72643c0ffd72",
    "heroImage":{
      "id" : "string",
      "url" : ""
    },
    "seoSlug": "mi-segundo-slug",

    "seoData": {
      "tags": [
        {
          "type": "meta",
          "props": {
            "name": "description",
            "content": "This is the blog template metadescription"
          },
          "children": "",
          "custom": false,
          "disabled": false
        }
      ],
      "settings": {
        "preventAutoRedirect": false,
        "keywords": []
      }
    },
    
    "richContent": {
      "nodes": [
        {
          "type": "HEADING",
          "id": "header-id-123",
          "nodes": [
            {
              "type": "TEXT",
              "id": "text-id-456",
              "nodes": [],
              "textData": {
                "text": "This is an H2 Element Title",
                "decorations": []
              }
            }
          ],
          "headingData": {
            "level": 2
          }
        },

        {
          "type": "IMAGE",
          "imageData": {
            "type": "SITE",
            "id": "476f91_6a17c8683f824a6daa9089e8969dd06b~mv2.jpg",
            "url": "https://static.wixstatic.com/media/9e94c3243314391af0e112ab0e3dc4a2.jpg",
            "height": 1694,
            "width": 3000,
            "filename": "agencia_SEM_Mexico_edited_edited.jpg",

            "siteData": {
              "url": "https://static.wixstatic.com/media/9e94c3243314391af0e112ab0e3dc4a2.jpg"
            }
          }
        },




        {
          "type": "HEADING",
          "id": "header-id-123",
          "nodes": [
            {
              "type": "TEXT",
              "id": "text-id-456",
              "nodes": [],
              "textData": {
                "text": "This is an H3 Element it will work for subheadings",
                "decorations": []
              }
            }
          ],
          "headingData": {
            "level": 3
          }
        },
        {
          "type": "PARAGRAPH",
          "id": "paragraph-id-012",
          "nodes": [
            {
              "type": "TEXT",
              "id": "text-id-345",
              "nodes": [],
              "textData": {
                "text": "This is paragraphh that works as a content expander of the previous subheading, will have this by many",
                "decorations": []
              }
            }
          ],
          "paragraphData": {
            "textStyle": { "textAlignment": "AUTO" },
            "indentation": 0
          }
        },
        {
          "type": "HEADING",
          "id": "header-id-123",
          "nodes": [
            {
              "type": "TEXT",
              "id": "text-id-456",
              "nodes": [],
              "textData": {
                "text": "This is an H4 and so on it will work for subheadings",
                "decorations": []
              }
            }
          ],
          "headingData": {
            "level": 4
          }
        },
        {
          "type": "PARAGRAPH",
          "id": "paragraph-id-012",
          "nodes": [
            {
              "type": "TEXT",
              "id": "text-id-345",
              "nodes": [],
              "textData": {
                "text": "This is paragraphh that works as a content expander of the previous subheading, will have this by many",
                "decorations": []
              }
            }
          ],
          "paragraphData": {
            "textStyle": { "textAlignment": "AUTO" },
            "indentation": 0
          }
        }
      ],

      "documentStyle": {
        "headerTwo": {
          "fontSize": "20px",
          "fontWeight": "bold",
          "color": "#333"
        },
        "paragraph": {
          "fontSize": "16px",
          "color": "#555"
        }
      }
    }
  }
}

Did you manage to get this to work?

On my end, I can’t retrieve a blog’s richContent property using the fieldsets query parameter. The documentation provides no guidance besides a “URL” field example. “RICHCONTENT” doesn’t work.

Hello! If you are still struggling with this, there are a few threads in our Discord server in the headless channel that may help you problem solve this.

For the heroImage issue, test using coverMedia. There was an issue with the deprecation of coverMedia which is affecting heroImage so you should be able to workaround this using coverMedia.

Here is the link to the Discord server if this is not enough info to get you moving Devs on Wix