Ultimate Goal:
Allow all files in a folder on a shared drive be publicly readable NOT editable.
Issue:
I have another simple problem that I'm sure is something silly I'm overlooking. I am simply trying to create a permission for a created drive folder on a shared drive to be publicly available via the link, as follows:
const getFolderPerms = await drive.permissions.create({
"fileId": `${createFolder.data.id}`,
"requestBody": [
{
"role": "reader",
"type": "anyone"
}
],
"supportsAllDrives": true,
"supportsTeamDrives": true
})
but when I attempt this I get the following error:
message: 'Required parameter: fileId',
I know its actually sending a id over, because if I console log it before:
console.log('id ? ' + createFolder.data.id)
it prints out:
id ? 1fXLmWLLT5pi5WnztO6sYTzRqerowVucF
What am I doing wrong?
I've tried moving the requestBody to various functions but have still not been successful.
message: 'Required parameter: fileId',
is due to the value of requestBody
.In your showing script, how about the following modification?
const getFolderPerms = await drive.permissions.create({
fileId: `${createFolder.data.id}`,
requestBody: {
role: "reader",
type: "anyone",
},
supportsAllDrives: true,
supportsTeamDrives: true,
});
In this modification, the value of requestBody
is changed from an array to an object of the 1st element of your array.
When this script is run with a valid file ID, I confirmed that the permission of the file could be changed.
By the way, I think that when your file ID is a valid value, both fileId: `${createFolder.data.id}`,
and fileId: createFolder.data.id,
can be used.