Skip to main content
Question

BOX search content API not working with email id

  • May 22, 2025
  • 18 replies
  • 81 views
  • Translate All

Forum|alt.badge.img

Search  content  API is not working when the content is a mail id. Is there any specific approach for this requirement?

18 replies

Forum|alt.badge.img

I'm not sure I understand what you mean by email id/mail id... can you elaborate? 

Translate

Forum|alt.badge.img

Thanks Alex for the fast reply.                                                                                                                                                                                                            

I am using search content API  to find files that contain a specific email id. When I used a word or a text in the query, it was working fine, but when I use an email id to be searched in the files, it is not working. It is show that no files have the specified email id in it's content.

Example : 'https://api.box.com/2.0/search?query='+emailId

The 'emailId' is actual present in a file. But the response returns zero entries.

Translate

Forum|alt.badge.img

This seems to be working now. It was because I did not add my service account as collaborator.

Another issue I am facing is that, even though service account was added as collaborator to the file and folder, search API is not giving desired output. This issue is shown in the company BOX account. Can you help me with this?

Translate

Forum|alt.badge.img

Can you show me what you mean about "shown in the company BOX account?"

 

Translate

Forum|alt.badge.img

I have a BOX application in my company BOX account. The search API is giving me 0 results but the status code is 200. I am facing this issue when I am logged into to my company BOX account. The same application exists in my personal BOX account which is giving me desired output. Can't find what is going wrong in the company BOX account.

 

Translate

Forum|alt.badge.img

Does the application you are using to search for content have access to the content you are looking for? Alot of times, I find that the service account of the application has not been collaborated when search results aren't being returned. 

Translate

Forum|alt.badge.img

The service account of the application has been collaborated with the search content as co-owner

Translate

Forum|alt.badge.img

You are searching for content in your company box account, using an application you made in your personal box account? Do you have the client id of the application? And may I see the code you are running? 

Translate

Forum|alt.badge.img

I am searching for a content in my company account using the application in the company account.

Client id: 2fhv5vzik0ssjsk8xpyw77t47ck88hnn

 

code:

var searchText =  document.getElementById('search_id').value;
           var url = 'https://api.box.com/2.0/search?query='+searchText;
            xmlHttp.open("GET", url, false );
            xmlHttp.setRequestHeader('Authorization', authorization);
            xmlHttp.send(null);
            var result = JSON.parse(xmlHttp.responseText);
 
Translate

Forum|alt.badge.img

To verify - this code works in when you use it in your personal box account? 

Translate

Forum|alt.badge.img

Yes. This code works fine in personal box account. Only difference I could find is few configurations missing in company account. Configuration are

1. Manage users

2. Manage web-hooks

3. Make API calls using the as-user headers

Translate

Forum|alt.badge.img

Did you create a second app in your personal? What is the client id for that one? 

Translate

Forum|alt.badge.img

Client Id for app in personal account : tsrgpp9as1jfmtl2wymfibzixff98yu1

Translate

Forum|alt.badge.img

It looks like the company application is configured a bit differently than the personal one. Can you confirm the company app has a selection here? As well as that the app has been authorized by an admin? 

BOX1_p4pZsrQ0N4kQrgN8MktM5Q.png

Translate

Forum|alt.badge.img

Okay. I will update this and get the app reauthorize. 

Will update you if that works.

 

Translate

Forum|alt.badge.img

Thanks. Not 100% this will work... it's odd that it's working in your personal... so something in the settings must be off. 

Translate

Forum|alt.badge.img

Unfortunately the above configuration cannot be approved for a company account.

 

Translate

Forum|alt.badge.img

I believe you have to have that app + enterprise access scope selected in order to use search for content not owned by the service account. 

Translate