Welcome to the new Box Support website. Check out all the details here on what’s changed.

Python SDK - remove shared link expiry - unshared_at = 'null'

Answered
New post

Comments

7 comments

  • jcleblanc

    @Hi ,

     

    Try None and see if that works for you, eg:

     

    link = file.get_shared_link(access=access_level, unshared_at=None);
    0
    Comment actions Permalink
  • rocks101

    Hi  ,

     

    Thanks for your response, I am only getting around to trying this now.

     

    When I pass "unshared = None" as suggested the shared link is created but it still pulls the default expiry settings from the tenant level, instead of removing the expiry.

     

    My current workaround is very messy as I am temporarily passing an expiry date in year 2099. Would you have time to test this yourself and confirm if there is a way to overwrite the enterprise settings when creating the shared link using Python SDK.

     

    Thanks in advance,

    Peter

     

    0
    Comment actions Permalink
  • jcleblanc

    Hi ,

     

    I ran some tests and was able to verify some results. I set my enterprise settings to expire shared links after 30 days as a default action. After that I ran the following code on a file within my service account:

     

    file_id = '449692210728'
    access_level = 'open'
    
    file = client.file(file_id)
      
    link = file.get_shared_link(access=access_level, unshared_at=None);
    print link

     

    I then pulled the shared link admin report to see if defining the shared at property to none was able to overwrite that admin setting, and it does not. The 30 day definition in the admin settings still applied.

     

    The admin level settings, in the case of keeping an open shared link, will supersede the attempt to set the shared link to an unset value. This will be a default used so you would either need to have some way of regenerating the shared link, using the workaround, or adjusting the admin settings.

     

    Thanks,

    Jon 

    0
    Comment actions Permalink
  • rocks101

    Thanks for testing and confirming same behaviour  ,

     

    • I'm not sure what good regenerating the shared link will actually do?
    • Changing the enterprise wide admin setting is not an option in this case. I guess for now I will need to stick with the workaround.

     

    I just tested this using Postman and it works when you send a null value in https request as below...do you think I should log this as an issue on the box-python-sdk or is it a python issue?

     

    curl -X PUT \
      https://api.box.com/2.0/files/\
      -H 'Authorization: Bearer ' \
      -d '{"shared_link": {"access": "Open", "unshared_at":null}}'

     

    Many thanks,

    Peter

    0
    Comment actions Permalink
  • rocks101

    raised an issue for (424) review

    0
    Comment actions Permalink
  • jcleblanc

    Thanks ,

     

    I chatted with the SDK team this morning, and here's what we were able to find out. The root of the issue seems to be in how the default value is being handled in the get shared link method. Essentially the default value is None, so when None is passed it is seeing this as a default value, not as a passed value. They've filed an internal JIRA ticket to review and adjust, as this issue also appears in other SDKs. I sent over your issue (thanks for filing that) and they'll communicate back and forth through that ticket as work is done.

     

    Let me know if anything pops up in the meantime that I can help with.

     

    - Jon

    0
    Comment actions Permalink
  • ESPINOZA, MARLENE /GA005

    Joh, my main shared folder is about to expire in 3 days. who can I contact to stop and edit the "SET AUTO-EXPIRATION"? Thank you.

    0
    Comment actions Permalink

Please sign in to leave a comment.