구글드라이브에 있는 이미지를 노션api에 업로드하여 노트를 작성하려고 하는데 (자바스크립트 기반)
계속
"Content creation Failed. Fix the following:
Invalid image url."
와 같은 오류가 뜨면서 안되네요...ㅜㅜ
혹시 아시는분 계실까요?
아래는 연동관련 헤더와 바디 부분입니다...
const databaseId = "데이터베이스 아이디";
const imgUrl = url
const headers = {
"Authorization": "Bearer " + data.apikey,
"Content-Type": "application/json",
"Notion-Version": "2021-08-16"
};
const body = {
"parent": {"database_id": databaseId},
"properties": {
"title": {"title": [{"text": {"content": data.title}}]}
},
"children": [
{
"object": "block",
"type": "image",
"image": {"type": "external", "external": {"url": "구글드라이브 이미지 공유url"}}
},
{
"object": "block",
"type": "paragraph",
"paragraph": {"text": [{"text": {"content": data.description}}]}
}
]
};
구글 드라이브 공유 URL 이 이미지만 바로 내려줄 것 같지 않네요.
구글드라이브의 공유 URL 이 구글드라이브 사이트 내에서 이미지가 보이는 주소가 아니라, 정말 이미지만 바로 볼 수 있는 직접 링크가 맞나요?
일단 여러 방법으로 테스트 해봤지만 안되더라구요;;;
노션 개발자노트를 보면 URL에 확장명이 붙어 있어야지만 되는 것 같기도 하고.. 또..
심지어 embed 옵션으로 테스트 해봤는데;;;;;
구글 드라이브 이미지만 안되는 것 같습니다. ㅠㅠ
https://stackoverflow.com/questions/15557392/how-do-i-display-images-from-google-drive-on-a-website
댓글 감사합니다.
해당 부분은 아래 링크 이용해서 테스트 해보긴 했는데.. 역시나 안되더라구요;
https://drive.google.com/uc?export=view&id=<파일ID>
그래도 다시 한번 보고
차근 차근 해봐야겠습니다.;;;
감사합니다.
https://developers.notion.com/reference/block#embed
"type": "embed",+ embed_uri( https://drive.google.com/uc?export=view&id=abcd )
조합은 어떠신가요?
https://developers.notion.com/reference/block#image 는,
`The image must be directly hosted. In other words, the url cannot point to a service that retrieves the image.` 라는데, embed 용이 아닌 download용uri( https://sites.google.com/site/gdocs2direct/ ; https://drive.google.com/uc?export=download&id=abcd ) 를 이용하면 되려나요..
https://developers.notion.com/reference/file-object#example-retrieve-a-link-to-an-external-file-using-get-children
감사합니다.
덕분에 겨우 해결했습니다. :)