Box Link validation using Boxsdk
Hi Team,
Please guide me on the below query.
Am having certain box links (direct and shared links) and need to validate if they are valid links or not. Is there a way to verify this using boxsdk?
Thanks in advance
-
Hi Rui,
Yes , I tried different methods ex: http request , python request library basically batch code. I was not able to get a proper response when I run them using batch code.
For Shared Links if its public then I get a 200 response else its 404.
One more scenario is for the folders that I have no access and just have a shared link then its accessible through browser but through batch code its 404.
-
That is odd indeed, and I was not able to replicate your situation.
So I did some testing and created 3 folders:
- shared link public
- shared link invite only w/ a user assigned
- an invalid shared link
With this code in python:
import requests
def main ():url_shared_public = 'https://app.box.com/s/v07pox0ni0xhd1b7bunmo8rebtp6o5jk'url_shared_invite = 'https://app.box.com/s/srqei60fa5b2h8o3zrlrpfxmwgz0dzss'url_shared_invalid = 'https://app.box.com/s/srqei60fa5b2h8o3zrlrpfxmwgz0dzsx'response = requests.get(url_shared_public)print(f" {url_shared_public}: {response.status_code}")response = requests.get(url_shared_invite)print(f" {url_shared_invite}: {response.status_code}")response = requests.get(url_shared_invalid)print(f" {url_shared_invalid}: {response.status_code}")if __name__ == "__main__":main()I get:
https://app.box.com/s/v07pox0ni0xhd1b7bunmo8rebtp6o5jk: 200
https://app.box.com/s/srqei60fa5b2h8o3zrlrpfxmwgz0dzss: 200
https://app.box.com/s/srqei60fa5b2h8o3zrlrpfxmwgz0dzsx: 404Even without any security context I'm getting a 200 code on a valid URL and a 404 on an invalid one.
When you test in the browser, make sure you are using an incognito window just to be sure you're not logged in any account.
For example the shared invite url first returns a 302 (redirect) and then the login page with 200
Perhaps there is a more elegant way of doing this, but I still do not understand why.
I wonder where do you get your shared links URL's and why you need to test them.
Are you using the shared links somewhere else and in the mean time they were removed?
Cheers
投稿コメントは受け付けていません。
コメント
3件のコメント