Skip to main content

I’m building an automation that triggers a folder creation in Box, then using that new folder I’d like to send the file_request url of that folder to a customer so they could upload documents to that folder. Each automation will have it’s own separate folder. The problem is I can’t seem to find a way to retrieve that file_request url for users to upload their files to unless I manually go into the console and copy it. Is there another way to automate this process? It seems silly that we can query the shared_link for a folder, but not the file_request. Any help would be appreciated. Thanks 

The solution we came up with to retrieve a File Request URL for a folder ID is a bit unusual. Because the Box API only seems to allow you to Copy an existing File Request onto another folder, we have a placeholder “DO NOT TOUCH” folder in a root location which we have enabled the File Request for from the Box web UI.

 

With that placeholder folder, we must obtain the File Request ID, which unintuitively is NOT the URL (app.box.com/f/12345) of the file request itself but rather an internal 11-digit request ID. And the only way I’ve found to get this is to open your Browser’s Developer Console Network Tab, and when you click to enable the File Request button in the UI, look out in your browser Network tab for the request to the https://app.box.com/app-api/file-request-web/file-request endpoint. In that response, you will see something like

{
    "folder": {
        "type": "folder",
        "id": "<folder_id>"
    },
    "id": "12303456842",
    "type": "file_request",
    "createdBy": {
        "type": "user",
        "id": "123456"
….

 

Luckily, you only need to do this step once, and from there you can use this “template” Request ID for all your folders.

Now with the internal File Request ID in hand, you can craft your programmatic call which will leverage Box API /file_requests/{file_request_id}/copy to apply the File Request URL to any given Folder ID.

curl -i -X POST "https://api.box.com/2.0/file_requests/12303456842/copy" \
     -H "authorization: Bearer <ACCESS_TOKEN>" \
     -d '{
       "title": "Document Upload",
       "description": "Please upload the required documents",
       "status": "active",
       "is_email_required": false,
       "is_description_required": false,
       "folder": {
         "id": "210432729657",
         "type": "folder"
       }
     }'

 

Then within that API response you should get a url value which will look like /f/19e57f40ace247278a8e3d336678c64a. Concatenate this value with https://app.box.com and you finally have your File Request URL.

 

Hopefully someone at Box can help clarify if there’s an easier way to achieve this, but this is the only way I have found as of now!

 


Thanks for the detailed response, Mike! This is actually the exact solution I came up. It’s good to have someone confirm it. It is a bit strange that it requires a file_id to create a new request (kind of like a template like you mentioned) instead of using a folder_id. But anyway, I’m just glad there’s a solution 😅.


Reply