Skip to main content
Question

Python Search API - returns nothing

  • May 27, 2025
  • 2 replies
  • 10 views

Forum|alt.badge.img

Hello Everyone,

All my searches come back with 0 entires.

I have tried 2 different sets of auth tokens from 2 different people and my searches always return nothing, but if I use the gui, I can find files.

my client seems to work as I am able to pull up user aliases, user disk usage etc, ie other api calls seem to work.

what doesnt work is my attempts at the search, i even tried like a make_request version. I could show that too.. but I am wondering if its something else now below is my code, then the most simple search I could try. (id's and filenames changed to protect the innocent)

I am running Python 3.6.7

boxsdk==2.12.1

PyJWT==1.7.1
requests==2.22.0

Any guidance would be much appreciated.

-Gary

I did try my "search" from the MAKE API CALL on the website, very cool btw, and it worked fine and showed me exactly what i was expecting.

 

#what i really want, but i have broken down
#items =client.search().query(query='file_i_know_exists', type="file", limit=100, file_extensions='pdf', owner_user_ids=["11111"], scope="user_content", fields='name' )
items =client.search().query(query='file_i_know_exists')
pprint.pprint(inspect.getmembers(items))
item_count = 0
for item in items:
print('The item ID is {0} and the item name is {1}'.format(item.id, item.name))
item_count = item_count + 1
if item_count == 0:
print("sdk items not found")

2 replies

Forum|alt.badge.img

Hi, 

What user are you using to the create the client? Does that user have access to the content you are searching for? 

Thanks, 

Alex, Box Developer Advocate


Forum|alt.badge.img

Ya thats I am thinking too. 

I setup my own token and clientID and apAuth, do I need to do something more do allow for box api content searching on the dev console ? I see there are other things I can allow.

I originally added this to the search 'owner_user_ids=["$MY_OWN_ID"]'  (note the commented out section thats me trying to search my own id) 

The item_count is always 0.

Thanks for the help!

-Gary