Search API
Hi,
I'll apologize in advance for not being terribly familiar with the Box API but I'm running into an issue where my search results are always empty.
I'm working on an application that is intended to allow us to automatically move files/folders (update their parent) based on their 'Classification' (and other business rules) after a certain period of time. The idea being that we run a service (having its own credentials) that has access to the Box account with the ability to update file's/folder's parent object.
The design I am hoping to implement is to have the application run on a schedule and search(enterprise-wide) for files/folders having a specific 'Classification' and whose created date is more than x days in the past. The problem I am having is when I post even a simple search it always comes back empty. I'm not sure if it's an issue with the client I am using and/or just not knowing how search works.
Currently I am using the .NET Core SDK - I establish my client like this:
var content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>(
"client_id", boxClientSettings.ClientId),
new KeyValuePair<string, string>(
"client_secret", boxClientSettings.ClientSecret),
new KeyValuePair<string, string>(
"grant_type", "client_credentials"),
new KeyValuePair<string, string>(
"box_subject_type", "enterprise"),
new KeyValuePair<string, string>(
"box_subject_id", boxClientSettings.EnterpriseId)
});
var httpClient = new HttpClient();
var response = httpClient.PostAsync("https://api.box.com/oauth2/token", content).Result;
var data = response.Content.ReadAsStringAsync().Result;
var token = JsonConvert.DeserializeObject<BoxAccessToken>(data);
accessToken = token.access_token;
var config = new BoxConfig(boxClientSettings.ClientId, boxClientSettings.ClientSecret, new Uri(boxClientSettings.RedirectUri));
var session = new OAuthSession(accessToken, "NOT_NEEDED", 3600, "bearer");
client = new Box.V2.BoxClient(config, session);
It works great from the standpoint that when I call the following endpoints the authentication works and I get back results - the calls below all give me results:
BoxEnterpriseMetadataTemplateCollection<BoxMetadataTemplate> organizationTemplates = await boxClient.MetadataManager.GetEnterpriseMetadataAsync();
BoxCollection<BoxUser> users = await boxClient.UsersManager.GetEnterpriseUsersAsync();
BoxCollection<BoxCollectionItem> collections = await boxClient.CollectionsManager.GetCollectionsAsync();
However, when I call any search endpoint it consistently comes back with 0 'Entries' but showing a 'TotalCount' of 191. The search looks like this. Any direction on what I am doing incorrectly or how to alter my approach would be very appreciated.
BoxCollection<BoxItem> searchResults = await boxClient.SearchManager.QueryAsync("test", scope: "enterprise_content");
Thanks!
サインインしてコメントを残してください。
コメント
0件のコメント