Community

개발자 99% 커뮤니티에서 수다 떨어요!

← Go back

노션 api 영상 최신버전으로 부탁드려도 될까요?

#ask
1년 전
3,212

https://youtu.be/XCAwSBdeejU

노션 Create a database 를 활용해보고 싶은데
위 영상 보고 따라해봤는데 안되서요...

  export default async function handler(req, res) {
  console.log(req.body);
  const 이름 = req.body.이름;
  const 주소 = req.body.주소;

  const options = {
    method: "POST",
    headers: {
      accept: "application/json",
      "content-type": "application/json",
      "Notion-Version": "2022-06-28",
      Authorization: `Bearer ${process.env.NOTION_API_TOKEN}`,
    },
    body: JSON.stringify({
      parent: {
        page_id: "fa70d49a007844f48ad8ef906d5f677d"
      },
      properties: {
        name: {
          title: [
            {
              text: {
                content: 이름,
              },
            },
          ],
        },
        address: {
          rich_text: [
            {
              text: {
                content: 주소,
              },
            },
          ],
        },
        
      },
    }),
  };

await fetch('https://api.notion.com/v1/databases', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

}



계속 에러만 나와요
(인증키/db아이디는 전부 확실합니다. 같은 값으로 DB를 불러오는 건 했는데, 데이터 추가만 못하겠네요...)

아래는 에러 내용입니다.

API resolved without sending a response for /api/test, this may result in stalled requests.

{

object: 'error',

status: 400,

code: 'validation_error',

message: 'body failed validation. Fix one:\n' +

'body.properties.name.number should be defined, instead was undefined.\n' +

'body.properties.name.formula should be defined, instead was undefined.\n' +

'body.properties.name.select should be defined, instead was undefined.\n' +

'body.properties.name.multi_select should be defined, instead was undefined.\n' +

'body.properties.name.status should be defined, instead was undefined.\n' +

'body.properties.name.relation should be defined, instead was undefined.\n' +

'body.properties.name.rollup should be defined, instead was undefined.\n' +

'body.properties.name.title should be an object, instead was [{"text":{"content":"1"}}].\n' +

'body.properties.name.rich_text should be defined, instead was undefined.\n' +

'body.properties.name.url should be defined, instead was undefined.\n' +

'body.properties.name.people should be defined, instead was undefined.\n' +

'body.properties.name.files should be defined, instead was undefined.\n' +

'body.properties.name.email should be defined, instead was undefined.\n' +

'body.properties.name.phone_number should be defined, instead was undefined.\n' +

'body.properties.name.date should be defined, instead was undefined.\n' +

'body.properties.name.checkbox should be defined, instead was undefined.\n' +

'body.properties.name.created_by should be defined, instead was undefined.\n' +

'body.properties.name.created_time should be defined, instead was undefined.\n' +

'body.properties.name.last_edited_by should be defined, instead was undefined.\n' +

'body.properties.name.last_edited_time should be defined, instead was undefined.\n' +

'body.properties.name.button should be defined, instead was undefined.\n' +

'body.properties.name.unique_id should be defined, instead was undefined.\n' +

'body.properties.name.location should be defined, instead was undefined.\n' +

'body.properties.name.verification should be defined, instead was undefined.\n' +

'body.properties.name.last_visited_time should be defined, instead was undefined.'

}