Downloading from SharedFolder API error Not found items
gosztidj opened this issue · comments
Hello!
We have a shared link that we want to automatically download from in C#, but when I want to access the contents of the folder, I get the following error:
BoxAPIException: The API returned an error [NotFound | crrdb2haxiqfe5eh.0a252b39d52f3d8f12b6e4c8d0b816a1e] not_found - Not Found
Why can't you find the items in the folder?
var config = new BoxConfig("CLIENT_ID", "", new Uri("http://localhost"));
var session = new OAuthSession("ACCESS TOKEN", "N/A", 3600, "bearer");
var client = new BoxClient(config, session);
string webLinkUrl = "https://samchully.app.box.com/v/Europe000000";
var user = client.UsersManager.GetCurrentUserInformationAsync().Result;
Console.WriteLine($"User: {user.Id}:{user.Name}");
Task <BoxItem> getsharedItems = client.SharedItemsManager.SharedItemsAsync(webLinkUrl);
BoxFolder sharedFolder = (BoxFolder)getsharedItems.Result;
var items = client.CollectionsManager.GetCollectionItemsAsync(sharedFolder.Id, 5000);
Console.WriteLine(items.Result);
Console.WriteLine("Id: " + sharedFolder.Id);
Hi @gosztidj,
Thanks for submitting your question, we are checking it and will get back to you ASAP.
Best regards,
Minh
Hi @gosztidj,
I just verified your code, and everything went well, so please verify if the shared link is correct and the user you are authenticating has permission to access the shared link.
If it still isn't working, please let me know.
Thank you.
This link does not require authentication, it is freely available.
What could be the problem?
Hi @gosztidj,
I think you should verify your shared link, it should start with https://username.box.com/s/
but not https://username.app.box.com/v/
, it's seem to be unusual, and keep in mind that it should be a shared link which you got from the share dialog or from create shared link function, but not copy it after it's navigating by the browser.
If this would not help reach out to support, they can deeply investigate your shared link to get a better resolution:
https://support.box.com/hc/en-us/requests/new
I hope this can help.
Best regards,
Minh
Hi @congminh1254 ,
Some progress has been made. /v in the link corresponds to viewer.
I tried to run the code with the python BOX SDK and it ran without errors, everything was downloaded from the given folder. The problem is that I would have to do this in a .NET program and it would run into an error.
Hi @gosztidj,
Thanks for your information, can you provide your code with Python SDK and for us to compare, then we will try to figure out what is going wrong :D
Have a nice week.
Minh Nguyen Cong
Hi @congminh1254,
This is working python code:
import os
import datetime
from boxsdk import JWTAuth, Client
def main():
auth = JWTAuth.from_settings_file(settings_file_sys_path='980952769_tidv16ck_config.json')
auth.authenticate_instance()
client = Client(auth)
CurrentDate=datetime.datetime.now()
print (CurrentDate)
web_link_url = "https://samchully.app.box.com/v/Europe000000"
user = client.user().get()
print(f"User: {user.id}:{user.name}")
shared_folder = client.get_shared_item(web_link_url,'' )
print(f"Shared Folder: {shared_folder.id}:{shared_folder.name}")
print("#" * 80)
print("Type\tID\t\tName")
os.chdir('downloads')
items = shared_folder.get_items()
download_items(items)
os.chdir('..')
def download_items(items):
for item in items:
if item.type == 'folder':
os.mkdir(item.name)
os.chdir(item.name)
download_items(item.get_items())
os.chdir('..')
if item.type == 'file':
print(f"{item.type}\t{item.id}\t{item.name}",end='')
with open(item.name,'wb') as download_file:
item.download_to(download_file)
print("\tdone")
if name == "main":
main()
print("Done")
Hi @gosztidj,
Can you try to submit the request manually with CURL with this following instruction Find folder for shared link
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/jsasdsd8sad24&shared_link_password=letmein"
The access_token
can be found in the Dev Portal.
Hi @congminh1254 ,
The folder_id was determined, the problem is that it does not return, or the ItemCollection is null and therefore the error is 404.
Hi @gosztidj,
I got your case. We identified the bug and will fix it as soon as possible, once again, thanks for your patience. I will let you know when the bug is fixed.
Have a nice day.
Thank you.
The missing fields were added in #892. It should be shipped soon with the new version of the SDK.
You can get items from folder with SharedLink by calling GetFolderItemsAsync
on FoldersManager
with shared link and optionally with a password.
// we need to have a sharedLink
var sharedLink = await boxClient.FoldersManager.CreateSharedLinkAsync(folder.Id, sharedLinkRequest);
// we need to get folderId somehow
var sharedItems = await boxClient.SharedItemsManager.SharedItemsAsync(sharedLink.SharedLink.Url, password);
var items = await boxClient.FoldersManager.GetFolderItemsAsync(sharedItems.Id, 100, sharedLink: sharedLink.SharedLink.Url,
sharedLinkPassword: password);