Search All Files

Runs a query on a set of files by using search criteria.

Note: For more information about this command, including descriptions of any path and request parameters, request body schema, response codes and schemas, and payload examples, refer to the online API reference for this command at the following web page:

Search all files

URI

https://bartendercloud.com/api/librarian/spaces/{spaceId}/files/search

Note: The bartendercloud.com domain that is referenced in the URI and in the code example that follows must be replaced with the contents of the DataCenterURI claim that is extracted from your access token. For more information, refer to Extracting the DataCenterURI Claim.

Path Parameters

spaceId

Type: Integer <int32>

Specifies the ID of the requested space. Use the number 1 to target the Main space or the number 2 to target the $temp space. Required.

Query Parameters

None.

Example

Request body: See SearchFilesRequest.

Response: See SearchFilesResult.

Copy
// Create the search request. 
// In this example, the request searches for hidden files whose name contains "bar." 
// Note: The comparison process is case-insensitive.
var searchRequest = new SearchFilesRequest() {
   SearchFileAttributeType = SearchFileAttributeTypes.OnlyHidden,
   FileNameContainsQuery = "Bar"
};

var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {accessToken}");

HttpRequestMessage request = new HttpRequestMessage() {
   RequestUri = new Uri($"https://bartendercloud.com/api/librarian/spaces/{spaceId}/files/search"),
   Content = new StringContent(JsonConvert.SerializeObject(searchRequest), Encoding.UTF8, "application/json"),
   Method = HttpMethod.Post
};

HttpResponseMessage msg = await httpClient.SendAsync(request);

if (msg.IsSuccessStatusCode)
{
   // The returned collection of matching files. If the value of SearchFilesResult.NextSearchFilesRequest is
   // not null, then it can be used to query the next set of files. If it is null, then the query has
   // completed and returned all records.
   return JsonConvert.DeserializeObject<SearchFilesResult>(await msg.Content.ReadAsStringAsync());
}