Create Web Link
Create Web Link
To create a web link in Box, you will need to provide our API with a folder
id
and the url
you want the web link to be linked to. The url
must start
with http://
or https://
.
cURL
curl -i -X POST "https://api.box.com/2.0/web_links" \
-H "authorization: Bearer <ACCESS_TOKEN>" \
-H "content-type: application/json" \
-d '{
"name": "Cloud Content Management",
"url": "https://box.com",
"parent": {
"id": "0"
}
}'
TypeScript Gen
await client.webLinks.createWebLink({
url: 'https://www.box.com',
parent: { id: parent.id } satisfies CreateWebLinkRequestBodyParentField,
name: getUuid(),
description: 'Weblink description',
} satisfies CreateWebLinkRequestBody);
Python Gen
client.web_links.create_web_link(
"https://www.box.com",
CreateWebLinkParent(id=parent.id),
name=get_uuid(),
description="Weblink description",
)
.NET Gen
await client.WebLinks.CreateWebLinkAsync(requestBody: new CreateWebLinkRequestBody(url: "https://www.box.com", parent: new CreateWebLinkRequestBodyParentField(id: parent.Id)) { Name = Utils.GetUUID(), Description = "Weblink description" });
Java
BoxFolder folder = new BoxFolder(api, id);
URL url = new URL("https://www.example.com");
folder.createWebLink("Link to Example", url, "This goes to an example page");
Python
web_link = client.folder(folder_id='12345').create_web_link('https://example.com', 'Example Link', 'This is the description')
print(f'Web Link url is {web_link.url} and its description is {web_link.description}')
.NET
var weblinkParams = new BoxWebLinkRequest()
{
Url = new Uri("http://www.example.com"),
Parent = new BoxRequestEntity()
{
Id = "22222"
}
};
BoxWebLink link = await client.WebLinksManager.CreateWebLinkAsync(weblinkParams);
Node
client.weblinks.create(
'https://www.box.com',
'22222',
{
name: 'Box Website!',
description: 'Cloud Content Management'
})
.then(weblink => {
/* weblink -> {
type: 'web_link',
id: '11111',
sequence_id: '0',
etag: '0',
name: 'Box Website!',
url: 'https://www.box.com',
created_by:
{ type: 'user',
id: '33333',
name: 'Example User',
login: 'user@example.com' },
created_at: '2015-05-07T15:00:01-07:00',
modified_at: '2015-05-07T15:00:01-07:00',
parent:
{ type: 'folder',
id: '22222',
sequence_id: '1',
etag: '1',
name: 'Bookmarks' },
description: 'Enterprise Cloud Content Management',
item_status: 'active',
trashed_at: null,
purged_at: null,
shared_link: null,
path_collection:
{ total_count: 2,
entries:
[ { type: 'folder',
id: '0',
sequence_id: null,
etag: null,
name: 'All Files' },
{ type: 'folder',
id: '22222',
sequence_id: '1',
etag: '1',
name: 'Bookmarks' } ] },
modified_by:
{ type: 'user',
id: '33333',
name: 'Example User',
login: 'user@example.com' },
owned_by:
{ type: 'user',
id: '33333',
name: 'Example User',
login: 'user@example.com' } }
*/
});
iOS
client.webLinks.create(
url: "https://www.example.com",
parentId: "22222",
name: "Link to Example",
description: "This goes to an example page"
) { (result: Result<WebLink, BoxSDKError>) in
guard case let .success(webLink) = result else {
print("Error creating web link")
return
}
print("WebLink \(webLink.name) was created at \(webLink.createdAt)")
}