Skip to main content
Box Employee
May 22, 2025 7:07 AM UTC
Question

name 'BoxAPIException' is not defined

My code is sorting and moving the files based on the file type. i am included a try and except block in case the file is already included in the folder, it should move to different folder. But i am getting below error

 

NameError                                 Traceback (most recent call last)
 in ()
     24 
     25 
---> 26         except BoxAPIException:
     27                 print('possible duplicate')
     28                 print('Copying ' + filesInEachFolder[j].name)

NameError: name 'BoxAPIException' is not defined

 Can someone help me with this issue

    2 replies

    Box Employee
    May 22, 2025 7:07 AM UTC

    The code worked when i changed my Exception class from BoxAPIException to Exception.

     

    Translate
    Box Employee
    May 22, 2025 7:07 AM UTC

     You could also add the following code to your file, to ensure that the name is defined:

     

    from boxsdk.exception import BoxAPIException
    Translate