Adds a shared link to a folder.
12345
The unique identifier that represent a folder.
The ID for any folder can be determined
by visiting this folder in the web application
and copying the ID from the URL. For example,
for the URL https://*.app.box.com/folder/123
the folder_id
is 123
.
The root folder of a Box account is
always represented by the ID 0
.
shared_link
Explicitly request the shared_link
fields
to be returned for this item.
Returns the base representation of a folder with a new shared link attached.
Returned when there is an incorrect permission combination
Returned when the access token provided in the Authorization
header
is not recognized or not provided.
Returned if the user does not have all the permissions to complete the update.
Returned if the folder is not found, or the user does not have access to the folder.
Returned if the folder_id
is not in a recognized format.
Returns an error when the If-Match
header does not match
the current etag
value of the folder. This indicates that the folder
has changed since it was last requested.
An unexpected client error.
curl -i -X PUT "https://api.box.com/2.0/folders/32423234?fields=shared_link" \
-H "authorization: Bearer <ACCESS_TOKEN>" \
-d '{
"shared_link": {
"access": "open",
"password": "mypassword",
"unshared_at": "2012-12-12T10:53:43-08:00",
"permissions": {
"can_download": false
}
}
}'
await client.sharedLinksFolders.addShareLinkToFolder(
folder.id,
{
sharedLink: {
access: 'open' as AddShareLinkToFolderRequestBodySharedLinkAccessField,
password: 'Secret123@',
} satisfies AddShareLinkToFolderRequestBodySharedLinkField,
} satisfies AddShareLinkToFolderRequestBody,
{ fields: 'shared_link' } satisfies AddShareLinkToFolderQueryParams,
);
client.shared_links_folders.add_share_link_to_folder(
folder.id,
"shared_link",
shared_link=AddShareLinkToFolderSharedLink(
access=AddShareLinkToFolderSharedLinkAccessField.OPEN, password="Secret123@"
),
)
await client.SharedLinksFolders.AddShareLinkToFolderAsync(folderId: folder.Id, requestBody: new AddShareLinkToFolderRequestBody() { SharedLink = new AddShareLinkToFolderRequestBodySharedLinkField() { Access = AddShareLinkToFolderRequestBodySharedLinkAccessField.Open, Password = "Secret123@" } }, queryParams: new AddShareLinkToFolderQueryParams(fields: "shared_link"));
// Optionally we can calculate and set the date when shared link will automatically be disabled
final long ONE_WEEK_MILLIS = 1000 * 60 * 60 * 24 * 7;
long unsharedTimestamp = System.currentTimeMillis() + ONE_WEEK_MILLIS;
Date unsharedDate = new Date(unsharedTimestamp);
BoxFolder folder = new BoxFolder(api, "id");
BoxSharedLinkRequest sharedLinkRequest = new BoxSharedLinkRequest()
.access(OPEN)
.permissions(true, true)
.unsharedDate(unsharedDate);
BoxSharedLink sharedLink = folder.createSharedLink(sharedLinkRequest);
folder_id = '11111'
url = client.folder(folder_id).get_shared_link(access='open', allow_download=False)
print(f'The folder shared link URL is: {url}')
var sharedLinkParams = new BoxSharedLinkRequest()
{
Access = BoxSharedLinkAccessType.open
};
BoxFolder folder = await client.FoldersManager.CreateSharedLinkAsync("11111", sharedLinkParams);
string sharedLinkUrl = folder.SharedLink.Url;
client.folders.update('12345', {
shared_link: {
access: "open",
password: "do-not-use-this-password",
unshared_at: "2022-12-12T10:53:43-08:00",
vanity_name: "my-shared-link",
permissions: {
can_view: true,
can_download: true
}
}
}).then(folder => {
// ...
})
client.folders.setSharedLink(forFolder: "11111", access: .open) { (result: Result<SharedLink, BoxSDKError>) in
guard case let .success(sharedLink) = result else {
print("Error setting folder shared link")
return
}
print("Folder shared link URL is \(sharedLink.url), with \(sharedLink.access) access")
}
{
"etag": "1",
"id": "12345",
"shared_link": {
"access": "open",
"download_count": 0,
"download_url": "https://app.box.com/shared/static/kwio6b4ovt1264rnfbyqo1.pdf",
"effective_access": "open",
"effective_permission": "can_download",
"is_password_enabled": false,
"permissions": {
"can_download": true,
"can_edit": false,
"can_preview": true
},
"preview_count": 0,
"unshared_at": "2020-09-21T10:34:41-07:00",
"url": "https://app.box.com/s/kwio6b4ovt1264rnfbyqo1",
"vanity_name": null,
"vanity_url": null
},
"type": "folder"
}