Notion Answers

Help between Notion users


Register & Ask

It's free & easy

Get answers

Answers, votes & comments

Vote and select answers

Receive points, vote and give the solution

Question

1vote

Why can't I update a page property using the API?

On Windows 10 using the Notion API ...

I'm trying to update one column (property) value in one row (page) of my database using cURL. I keep getting an error when I send the following with appropriate replacements for the square bracketed [ ] items:

curl https://api.notion.com/v1/pages/[the_page_id] -H "Authorization: Bearer [my_secret]" -H "Content-Type: application/json" -H "Notion-Version: 2022-06-28" -X PATCH --data '{"properties": {"Plot": { "text": "Hello" }}}'

"Plot" is the name of the column/property and "Hello" is the value with which I'm trying to update that column/property in the page specified by the PageID.

Here is the returned error:

      {"object":"error","status":400,"code":"invalid_json","message":"Error parsing JSON body."}
      curl: (3) unmatched brace in URL position 1:
      {Plot:
       ^

As you can see, there is no unmatched brace (unless I am misinterpreting the error message). I tried switching the single and double quotes in the --data section with the same results. I tried replacing "text" with "rich_text" with the same results.

This almost exactly mimics the example provided by the Notion documentation here: https://developers.notion.com/reference/patch-page

What am I doing wrong? Thanks.

1 Answer

1vote

Hi,

not sure if this is still an issue that you need help with but here is an answer I could think of regardless.

The most straightforward approach that comes to mind would be to use a separate .json file for your data. This avoids any potential issues with command line quoting and makes it easier to manage and edit your JSON data.
This is how I would approach it.

Steps:

  1. Create a file named data.json with the following content:
{
  "properties": {
    "Plot": {
      "text": "Hello"
    }
  }
}
  1. Use the following cURL command:
curl https://api.notion.com/v1/pages/[the_page_id] -H "Authorization: Bearer [my_secret]" -H "Content-Type: application/json" -H "Notion-Version: 2022-06-28" -X PATCH --data @data.json

This method should ensure that the JSON data is correctly formatted and avoids any potential issues with command line quoting.

Martin

Please log in or register to answer this question.

...

Welcome to Notion Answers, where you can ask questions and receive answers from other members of the community.

Please share to grow the Notion Community!

Connect