question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Appending an image block fails: "APIResponseError: Content creation Failed. Fix the following Invalid image url."

See original GitHub issue

Describe the bug When adding a new image block I get the error “APIResponseError: Content creation Failed. Fix the following Invalid image url.”.

To Reproduce Node version: v15.14.0 Notion JS library version: 0.4.2

Steps to reproduce the behavior:

import { Client } from "@notionhq/client"
const notion = new Client({ auth: "<some-secret-auth-token>" })

async function addImageBlock() {
  const blockId = '<some-block-id>';
  const response = await notion.blocks.children.append({
    block_id: blockId,
    children: [
      {
        "type": "image",
        "image": {
          "type": "external",
          "external": {
              "url": "https://211009og3x5i5niup7w.nextcloud.hosting.zone/s/f3bYd42yi7nWPLR/preview"
          }
        }
      },
    ],
  })
}

addImageBlock()

Expected behavior The image block should created as expected

Additional context I know, that in principle the method call to add a block does work. I was able to confirm that using another image URL for example https://images.unsplash.com/photo-1633074320366-365b5e382fb5 Therefore, I suspect the image hosting provider is the actual problem but when comparing both of the images in the browser using the inspector tools, I was not able to detect any major differences.

However, adding an image block manually in the notion app works perfectly for both urls.

  1. Since the manual creation of image blocks works for both urls, I think the api should be able to handle both urls as well
  2. If this is not possible, I would suggest to have the actual requirements for such hosted ressources written in the documentation

Any help is much appreciated.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
dev-techmoecommented, Nov 2, 2021

The image URL needs to have a file extension at the end of it. For example, in the URL you have listed the URL should have an image extension after “preview” matching the file type it points to. Please try this and let us know

https://211009og3x5i5niup7w.nextcloud.hosting.zone/s/f3bYd42yi7nWPLR/preview.jpg

We support the following extensions: png jpg jpeg gif tif tiff bmp svg heic

We also support Unsplash URLs without the need for extensions.

Hey @alfonsodlopez , thank you for your reply. I tested it and API returns success, but in my option, it’s not a good design because there are too many services that can’t provide a permalink with that extensions for images, such as the image of Nextcloud above (and https://211009og3x5i5niup7w.nextcloud.hosting.zone/s/f3bYd42yi7nWPLR/preview.jpg is not a correct link for this image, it returns a login page). I tested the official client of Notion is not have this limitation, I don’t understand why API has it, so I think if we want to check the filetype of the target for some reason we should check the content-type header or some similar of our links, not just an extension in URL because it causes too many troubles for development.

1reaction
cambaughncommented, Oct 12, 2021

I’m getting a similar (but distinct) error that just started today.

@notionhq/client warn: request fail {
  code: 'validation_error',
  message: 'Block type image is not supported.'
}

It was working fine last night to add image embeds into a page while creating the page:

notion.pages.create(
{
    parent: { database_id: database_id },
    properties: {
      // properties
    },
    children: [
      {
        object: 'block',
        "type": "image",
        "image": {
          "type": "external",
          "external": {
              "url": someurl
          }
        }
      }
    ]
  }
)

I wonder if there’s something going on with the image blocks part of the api.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solved: Invalid Image URL - Marketing Nation - Marketo
Hi all- Wondering if something recently changed in Marketo. I upload and image file and when I select it in the email to...
Read more >
Avoiding the dreaded “Invalid Image URL” error with ...
How to fix it. The solution is so, so simple. Upload an image whose name matches the literal URL — with the curly...
Read more >
Invalid Image url - java - Stack Overflow
When I try to run the same code, with the src organized the same way, I get an invalid URL or resource not...
Read more >
Image URL related error creating category via REST API
Hi, I am having a problem trying to use the API to create a Product Category with an image. I am using the...
Read more >
How to fix: Invalid image - Google Merchant Center Help
Ensure the image is accessible and uses an accepted image format (JPEG , WebP, PNG, GIF, BMP, and TIFF)The URL provided for either...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found