Web links are objects that point to URLs. These objects are also known as bookmarks within the Box web application. Web link objects are treated similarly to file objects, so they will also support shared links, copy, permanent delete, and restore.
- Create a Web Link
- Get a Web Link's information
- Update a Web Link
- Delete a Web Link
- Copy a Web Link
- Create or update a Shared Link
- Remove a Shared Link
To create a web link call WebLinksManager.CreateWebLinkAsync(BoxWebLinkRequest createWebLinkRequest)
.
var weblinkParams = new BoxWebLinkRequest()
{
Url = new Uri("http://www.example.com"),
Parent = new BoxRequestEntity()
{
Id = "22222"
}
};
BoxWebLink link = await client.WebLinksManager.CreateWebLinkAsync(weblinkParams);
You can request a web link object by ID by calling WebLinksManager.GetWebLinkAsync(string webLinkId)
with the ID of the web link object.
BoxWebLink link = await client.WebLinksManager.GetWebLinkAsync("11111");
To update a web link call the
WebLinksManager.UpdateWebLinkAsync(string webLinkId, BoxWebLinkRequest updateWebLinkRequest)
method with the fields to update and their new values.
var updates = new BoxWebLinkRequest()
{
Name = "New Name for Weblink"
};
BoxWebLink updatedLink = await client.WebLinksManager.UpdateWebLinkAsync("11111", updates);
To move a web link to the trash call WebLinksManager.DeleteWebLinkAsync(string webLinkId)
with the ID of the web link object to delete.
await client.WebLinksManager.DeleteWebLinkAsync("11111");
To make a copy of a web link, call WebLinksManager.CopyAsync(string webLinkId, string destinationFolderId, IEnumerable<string> fields = null)
with the ID of the web link and the ID of the folder into which it should be copied.
BoxWebLink copiedLink = await client.WebLinksManager.CopyAsync("11111", "22222");
A shared link for a web link can be created or updated by calling
WebLinksManager.CreateSharedLinkAsync(string id, BoxSharedLinkRequest sharedLinkRequest, IEnumerable<string> fields = null)
.
string webLinkId = "11111";
var sharedLinkParams = new BoxSharedLinkRequest()
{
Access = BoxSharedLinkAccessType.open
};
BoxWebLink link = client.WebLinksManager
.CreateSharedLinkAsync(webLinkId, sharedLinkParams);
string sharedLinkUrl = link.SharedLink.Url;
To remove a shared link from a web link, call
WebLinksManager.DeleteSharedLinkAsync(string id, IEnumerable<string> fields = null)
with the ID of the web link.
BoxWebLink updatedLink = client.WebLinksManager.DeleteSharedLinkAsync("11111");