I Try to run this script in google sheet to get update data from notion Database
function updatePage() {
let token = 'secret_hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh';
let pageId = '77777777777777777777777777777777';
let props = {
"properties": {
"[The Property Name]": {
//in the case of a text field:
"rich_text": [{
"text": {
"content": "[The New Value!]"
}}]}}};
let options = {
"method": 'patch',
headers: {
"Content-Type": "application/json",
"Notion-Version": "2022-02-22",
"Authorization": "Bearer " + token
},
"payload": JSON.stringify(props),
"redirect": "follow"
};
let url = 'https://api.notion.com/v1/pages/'+pageId;
let response = UrlFetchApp.fetch(url,options);
Logger.log(JSON.parse(response.getContentText()));
}
when I run it keep show error
Exception: Request failed for https://api.notion.com returned code 404. Truncated server response: {"object":"error","status":404,"code":"object_not_found","message":"Could not find page with ID: 77777777-7777-7777-7777-777777777777. Make sure th... (use muteHttpExceptions option to examine full response)
I get the page ID from Share URL
the page still existed I have try the api url
https://api.notion.com/v1/pages/77777777777777777777777777777777
it's return with
{"object":"error","status":401,"code":"unauthorized","message":"API token is invalid."}