Box File Request API

Answered
New post

Comments

11 comments

  • Kourtney

    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

    0
    Comment actions Permalink
  • Kevin Ford

    Hi Kourtney,

    Thanks for responding. 

    App client ID: swy2gpdpdv0rubo8cu3flmtlhjtnsrcv

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

    File request ID: 598720367

    KF

    0
    Comment actions Permalink
  • Michael Dorr

    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

    0
    Comment actions Permalink
  • Kevin Ford

    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. 

     

     

    0
    Comment actions Permalink
  • Kourtney

    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

    0
    Comment actions Permalink
  • Darren Setter

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

    0
    Comment actions Permalink
  • Kevin Ford

    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)
    0
    Comment actions Permalink
  • Darren Setter

    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.

    0
    Comment actions Permalink
  • Darren Setter

    @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)
    0
    Comment actions Permalink
  • Kevin Ford

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

    0
    Comment actions Permalink
  • Kevin Ford

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

    0
    Comment actions Permalink

Please sign in to leave a comment.