Appending an image block fails: "APIResponseError: Content creation Failed. Fix the following Invalid image url."
See original GitHub issueDescribe 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.
- Since the manual creation of image blocks works for both urls, I think the api should be able to handle both urls as well
- 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:
- Created 2 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top GitHub Comments
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 thecontent-type
header or some similar of our links, not just an extension in URL because it causes too many troubles for development.I’m getting a similar (but distinct) error that just started today.
It was working fine last night to add image embeds into a page while creating the page:
I wonder if there’s something going on with the image blocks part of the api.