Level up your Box knowledge with brand new learning paths on Box University. Visit training.box.com to get started

Delay before newly created folder (via the API) can be found by name

New post

Comments

5 comments

  • jcleblanc

    Hi ,

     

    Can you walk me through how you're trying to load the files (e.g. the endpoint or method, are you using search, etc.) and what errors you're seeing please?

     

    Typically the 5-10min indexing time applies to search indexing time, but the above data should help us try to figure this out.

     

    Thanks,

    Jon

    0
    Comment actions Permalink
  • dev_cpt

    Hi Jon

     

    Basically we are using this endpoint  

    https://api.box.com/2.0/folders

    to create a folder and the response is along the lines of 

    {"name":"John Doe 3 2020_04_28","parent":{"id":"1116XXXXXXX"}}

     

    Then we use the endpoint  

    https://api.box.com/2.0/search?query=FOLDERNAME&type=folder&fields=id,name

    but any request lest than 10 mins apart gets the response that no folder exists

    {"total_count":0,"entries":[],"limit":30,"offset":0}

     

    https://upload.box.com/api/2.0/files/content

    0
    Comment actions Permalink
  • jcleblanc

    Hi ,

     

    Thanks for the additional context. Based on the second search call that will definitely be the problem. The search endpoint will always have a 5-10min indexing delay for file in the current implementation. 

     

    What I would recommend doing is this: when you are creating new content you can capture the API response from the content create / upload, which will give you data about the new object immediately (e.g. name, ID, etc.). You can then intermix that with the results you get from searching for any other content that you'd like to expose. 

     

    - Jon

    0
    Comment actions Permalink
  • dev_cpt

    Thanks Jon... So we should be using the folder ID rather than searching for the folder name and using that... I assume that if we use the folder ID, we dont need to wait for any search indexing. 

    0
    Comment actions Permalink
  • dandennhardt

     - That's right. Any direct lookup by an item's id value should be immediately available after a succesful create or update action. It's also generally the fastest way to get at an item, so if you have the luxury of knowing the id and keep it around for the session that's going to yield the best performance. Anything through the Search API (i.e. requests starting with api.box.com/2.0/search) will be subject to the indexing delay as the content is processed for search indexing.


    If you have a use case that requires an immediate lookup but you can't or don't want to keep around the id value, one option is to use the newly available Metadata Query API. With it, you can add custom metadata to files or folders and then query them immediately. It doesn't have provide the fuzzy searching that the Search API does, but if you have well-structured metadata, it may be a good choice. Read more about it here: https://developer.box.com/guides/metadata/queries/

    0
    Comment actions Permalink

Please sign in to leave a comment.