Skip to main content
Question

Loading a BoxFile Object

  • May 21, 2025
  • 4 replies
  • 23 views

Forum|alt.badge.img

Hi,

 

I am doing a search through Box API looking for files with particular "file name". The search is giving me back the details of the file as a JSon element. The question is how can i load a BoxFile object using that Json element? I need to load that BoxFile object and do some changes to its shared link. 

 

Note: Medium is Java.

 

Any help is appreciated.

 

Regards,

Magesh Kumar.

4 replies

Forum|alt.badge.img

Hello my friend,

 

You should do more research on your own, read the API documentation before you post questions.

 

Any way, file object is just for file. To update shared link you should use shared link API:

for instance:

curl https://api.box.com/2.0/files/FILE_ID?fields=shared_link \
-H "Authorization: Bearer ACCESS_TOKEN" \
-d '{"shared_link": {"access": "open", "password" : "topsecretdoc"}}' \
-X PUT

use the FILE_ID that you obtained from the file object.

 

For more see this link:

https://developer.box.com/v2.0/reference#get-shared-link

 

Hope this helps.

thanks,

Bibek 


Forum|alt.badge.img

Hi Bibek,

 

Thanks for your response. Sorry i am new to the API and this is an urgent requirement to set the expiration dates of all our shared links to null. Can you please suggest me solution for this in Java.

 

Thanks in advance!

 

Regards,

Magesh Kumar.


Forum|alt.badge.img

Hi Magesh,

I do not use Java language but it doesn't matter which language you use. 

To update the expiration date you should use:

 

curl https://api.box.com/2.0/files/1234?fields=shared_link \
-H "Authorization: Bearer ACCESS_TOKEN" \
-d '{"shared_link": {"unshared_at":"2017-05-30"}}' \
-X PUT

This e.g. updates shared link for file id 1234 to May 30 of 2017.

 

You only need to convert this to Java. Not sure how you are using it (either via plain Java or using Box SDK). But it's pretty much staright forward to do this. 

 

thanks, 

Bibek

 


Forum|alt.badge.img

Thanks Bibek. Will work on this further 🙂

 

Regards,

Magesh Kumar.