Skip to main content
Question

Box File Request API

  • May 22, 2025
  • 12 replies
  • 13 views

Forum|alt.badge.img

Hello,

I've been trying for weeks to get the new File Request API working. I'm using the Python SDK and my app is configured with JWT. For now, I'm just using the Python SDK to generate the bearer access token and putting it into Postman.

When I use the SDK generated bearer access token, the server returns a 500 error. However, if I make the exact same call using a Dev Token from the Dev Console it returns the file request as expected. I do, however, know that the bearer token I generate via the SDK is valid because if I use it to make any other call (get folder info, for example), it works as expected. The issue is only when making a call to https://api.box.com/2.0/file_requests/FILE_REQUEST_ID.

Thanks in advance.

12 replies

Forum|alt.badge.img

Hey Kevin, 

Hmm that's very strange. I'll need some details in order to further troubleshoot. If you're comfortable providing more information here, I'll need:

  • App's client ID 
  • Date/time/timezone of an example 500 
  • File ID you were trying to generate this file request for 

Alternately, you can open a support ticket with the information above.

Best,

Kourtney, Box Developer Advocate


Forum|alt.badge.img

Hi Kourtney,

Thanks for responding. 

App client ID: swy2gpdpdv0rubo8cu3flmtlhjtnsrcv

Timestamp: Fri, 12 Feb 2021 19:25:35 GMT

File request ID: 598720367

KF


Forum|alt.badge.img

Hi,

 

For what it's worth, I can confirm the same problem (internal server error when trying to copy a file request with primary access token, but it works with a dev token):

App client ID zld8nzl5kya1us4va23nb51mhcnsl7we

Timestamp Thu, 18 Feb 2021 19:48:22 GMT

File request ID 636458360

 

Thanks for looking into this issue,

Michael


Forum|alt.badge.img

I should add I've had a ticket (2334377) open on this for a few months now. Unfortunately, we haven't gotten anywhere with it so I thought I'd try a parallel request. 

 

 


Forum|alt.badge.img

Hey Kevin, 

Apologies on the delay getting back to you. I believe I was just able to reproduce the behavior you're seeing and have connected with the assigned agent to go ahead and open a bug ticket with our engineering team. To ensure we cover all of our bases and get this addressed for you as quickly as possible you may also want to open an issue directly to the Github repository. 

Best,

Kourtney, Box Developer Advocate


Forum|alt.badge.img

Did this get resolved? Can you share your code with how to get this working using python sdk + jwt?


Forum|alt.badge.img

No, not resolved. But here's the code:

from boxsdk import JWTAuth
import requests
import json

f_req_id = "599230332"  # File request template ID
folder_id = "126334743164"  # Folder ID to apply file request template

config = json.load(open("production_config.json"))

box_auth = JWTAuth.from_settings_file("production_config.json")
access_token = box_auth.authenticate_instance()

req_data = {"folder": {"id": folder_id, "type": "folder"}}

url = "https://api.box.com/2.0/file_requests/" + f_req_id
headers = {"Authorization": f"Bearer {access_token}"}
payload = json.dumps(req_data)

session = requests.Session()
response = session.post(url=url, data=payload, headers=headers)
print(response.content)

Forum|alt.badge.img

Thanks for that. I was hoping there was a solve! I'm having the exact same issue, 500 error when I generate and use an access token, but everything works fine when using a developer token.


Forum|alt.badge.img

@Kevin Ford, I was able to get this working. The file request I'm trying to access was not loaded by the service account but by a user. In all other instances this has happened I've had to use the as-user functionality in the API. This turned out to be the same issue here, I had to generate a user token and that worked. Code below. I hope this helps you!

from boxsdk import JWTAuth, Client
import requests

config = JWTAuth.from_settings_file("config.json")
client = Client(config)

as_user_id = '123456789'
user = client.user(user_id=as_user_id)
access_token = config.authenticate_user(user)

Forum|alt.badge.img

I haven't tried it yet @Darren Setter but thanks so much for that!


Forum|alt.badge.img

Darren you're my hero. I finally got the app permissions changed and reauthorized and it works now. 


Forum|alt.badge.img

I'm having the same issue here.

Will using the user_id work copy the file request to the Service account? I need a file request template in the Service account, so that I can create file requests there.