Skip to content

Latest commit

 

History

History
116 lines (90 loc) · 3.53 KB

web-links.md

File metadata and controls

116 lines (90 loc) · 3.53 KB

Web Links

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

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);

Get a Web Link's information

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");

Update a Web Link

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);

Delete a Web Link

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");

Copy a Web Link

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");

Create or update a Shared Link

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;

Remove a Shared Link

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");