Imagine a database table with two columns, Name
(title) and Collaborators
(relation). Things work fine when I add a row with a single collaborator like so.
qveri <- list(
parent = list(database_id = "database_id"),
properties = list(
Name = list(
title = list(
list(text = list(content = "klekele"))
)
),
"Collaborators" = list(
relation = list(
list(id = "hash_collaborator_1"))
)
)
)
out <- POST(
url = "https://api.notion.com/v1/pages",
add_headers("Authorization" = paste("Bearer", "notion_key"),
"Notion-Version" = "2021-05-13"),
body = qveri,
encode = "json"
)
> out$status_code
[1] 200
Things get tricky when I try to insert more than one collaborator into the field. The error message is validation_error
but other than that, the spaghetti indicating where the error might be are pretty uninformative:
$message
[1] "body failed validation. Fix one:
\nbody.properties.Collaborators.title should be defined, instead was `undefined`.
\nbody.properties.Collaborators.rich_text should be defined, instead was `undefined`.
\nbody.properties.Collaborators.number should be defined, instead was `undefined`.
\nbody.properties.Collaborators.url should be defined, instead was `undefined`.
\nbody.properties.Collaborators.select should be defined, instead was `undefined`.
\nbody.properties.Collaborators.multi_select should be defined, instead was `undefined`.
\nbody.properties.Collaborators.people should be defined, instead was `undefined`.
\nbody.properties.Collaborators.email should be defined, instead was `undefined`.
\nbody.properties.Collaborators.phone_number should be defined, instead was `undefined`.
\nbody.properties.Collaborators.date should be defined, instead was `undefined`.
\nbody.properties.Collaborators.checkbox should be defined, instead was `undefined`.
\nbody.properties.Collaborators.relation should be defined, instead was `undefined`.
\nbody.properties.Collaborators.files should be defined, instead was `undefined`.
\nbody.properties.Collaborators.status should be defined, instead was `undefined`.
\nbody.properties.Name.id should be defined, instead was `undefined`.
\nbody.properties.Name.name should be defined, instead was `undefined`.
\nbody.properties.Name.start should be defined, instead was `undefined`."
While trying to insert more than one entry, I have tried various ways to replace the "Collaborators"
value in the qveri
variable, including but not limited to:
Collaborators = list(
relation = list(
list(
id = list(
data.frame(id = c("hash_collaborator1",
"hash_collaborator2")
)
)
)
)
)
Collaborators = list(
relation = list(
data.frame(id = c("hash_collaborator1",
"hash_collaborator2")
)
)
)
Collaborators = list(
relation = list(
id = as.list(
c("hash_collaborator1",
"hash_collaborator2")
)
)
)
"Collaborators" = list(
relation = list(
list(id = list("hash_collaborator1",
"hash_collaborator2")))
)
Any guidance where the documentation could be of help or on how to properly construct the query in order to insert more than one collaborator will be much appreciated.