日本時間5月16日のContent Cloud Summitで、カスタムアプリにBox AI APIを活用する方法を紹介します。

詳細を表示

共有リンクの項目の検索

ガイド 共有リンク 共有リンクの項目の検索

共有リンクの項目の検索

共有リンクの項目を検索APIは、BoxApiヘッダーを使用して共有リンクを入力として受け取り、その共有リンクが設定されているファイルまたはフォルダオブジェクトを返します。

共有リンクに関連付けられているファイルオブジェクトまたはフォルダオブジェクトを取得するには、リクエストの際に共有リンクの完全なURLを指定します。

cURL
curl -i -X GET "https://api.box.com/2.0/shared_items" \
     -H "authorization: Bearer <ACCESS_TOKEN>" \
     -H "boxapi: shared_link=https://app.box.com/s/gjasdasjhasd&shared_link_password=letmein"
Java
String sharedLink = "https://app.box.com/s/abcdefghijklmnopqrstuvwxyz123456";
String password = "foo";
BoxItem.Info itemInfo = BoxItem.getSharedItem(api, sharedLink, password);
Python
file = client.get_shared_item('https://app.box.com/s/gjasdasjhasd', password='letmein')
Node
client.sharedItems.get(
    'https://app.box.com/s/1a2b3c4d5e',
    null,
    {fields: 'type,id,parent,extension,shared_link'},
    callback
);
iOS
client.sharedItems.get(
    sharedLinkURL: "https://app.box.com/s/qqwertyuiopasdfghjklzxcvbnm123456"
) { (result: Result<SharedItem, BoxSDKError>) in
    guard case let .success(item) = result else {
        print("Error resolving shared item")
        return
    }

    print("The shared link resolves to item:")
    switch item {
    case let .file(file):
        print("- File \(file.name) (ID: \(file.id))")
    case let .folder(folder):
        print("- Folder \(file.name) (ID: \(file.id))")
    case let .webLink(webLink):
        print("- Web Link \(file.name) (ID: \(file.id))")
    }
}

共有リンクがフォルダに対するものである場合、このAPIのレスポンスには、そのフォルダ内のネストされた項目のリストが含まれないことに注意してください。

フォルダ内の項目をさらにトラバースするには、同じBoxApiヘッダーを使用して、ネストされたフォルダ情報を取得するこれらのフォルダ内の項目をリストするネストされたファイル情報を取得する、またはファイルをダウンロードしてください。