cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We love to hear how every person gets the most from Dropbox, and it seems everyone has a slightly different use for it - tell us yours here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

api dropbox_find_file

api dropbox_find_file

sjn001tvh
Explorer | Level 3

Greetings, I have experienced a rather perplexing situation.  I'm using Pipedream workflow steps to initiate Dropbox api calls, and they have been working perfectly.  I have a Dropbox directory where I place some text files that I use as parameter files.  I have successfully processed and downloaded one file from the directory in one of my workflows, but in another workflow, using the same calls as before but with a different filename, it returns "file not found".  I even tried the same filename as before, and got the same results.  I successfully executed the call to list files in the folder and the file exists, and I tried to use that reference to the file and still file not found.

 

Here's the code that I use in the first workflow (which works fine),

-------------------------------------------

async (events, steps, auths) => {

const fetch = require('isomorphic-fetch'); 
const { Dropbox } = require('dropbox'); 
const dbx = new Dropbox({ 
  accessToken: auths.dropbox.oauth_access_token, 
  fetch 
});

var filterFilesInResults = function (results) {
    var filteredResults = [];
    for (var k in results) {
        if (results[k] && "file" == results[k].metadata[".tag"]){
            filteredResults.push( results[k]);
        }
    }
    return filteredResults;
};

this.filepath = params.file_path || ''

try {
  this.resp = await dbx.filesSearch({
    query: params.query, 
    path: this.filepath, 
    mode: params.search_mode, 
  });

  var filtered = filterFilesInResults(this.resp.matches);  
  this.resp.matches = filtered;  
catch (err) {
  this.err = err;
}
}
------------------------------------------
 
This works great and I'm able to process the information from the file.
 
However, when I implemented the same call in a different workflow, using the same code and changing the name of the file, the following error occurs.
 
steps.dropbox_find_file.filepath:/workflowapps_paramfiles/clickup_api_params.def
error:Error in call to API function "files/search": request body: missing required field 'query'
 
I'm using the same code as shown above, but simply changing the name of the file.  And yet each time I execute the code, I get the response error shown above.  Like I mentioned before I have tried listing the files in the folder, and I select the file from the list returned by the call to dropbox_list_folder, but the same error occurs.  
 
What am I missing that triggers this error, when I haven't changed any of the code, but only the name of the file that I want to select?
 
Any input would be appreciated.  Thanks.
1 Reply 1

Re: api dropbox_find_file

Greg-DB
Dropboxer

The error from the Dropbox API here "Error in call to API function "files/search": request body: missing required field 'query'" indicates that the call was rejected because it did not include the required parameter "query".

 

From the code you shared though, I see you are setting the "query" parameter for the "filesSearch" method, so the SDK should be setting that in the request.

 

Can you check what the value of 'params.query' is? If it's not defined, that could result in this issue.

Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?