Welcome to the new Box Support website. Check out all the details here on what’s changed.

Download only one latest file in a box folder

Answered
New post

Comments

3 comments

  • Official comment
    Alex Novotny

    Hi Nitesh, 

    In order to use the download file endpoint, you would need to know the file id. You can use the search endpoint to search for files in a particular folder based on the updated date. The exact functionality you are looking for doesn't exist, but you can do the above to achieve the same results.  

    Thanks, 

    Alex, Box Developer Advocate

    Comment actions Permalink
  • Nitesh Singhal

    Thanks @Alex for your response. I am trying to generate the access token to use this API call but it's giving me error.

    $ curl -i -X POST "https://app.box.com/oauth2/token" \
    > -H "Content-Type: application/x-www-form-urlencoded" \
    > -d "client_id=tylxxxxxxung57" \
    > -d "client_secret=yaSGxxxxxxmvxa" \
    > -d "code=J30xxxxxJz" \
    > -d "grant_type=authorization_code"
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    100 257 0 100 100 157 126 197 --:--:-- --:--:-- --:--:-- 326HTTP/1.1 400 Bad Request
    Date: Sun, 26 Sep 2021 05:53:01 GMT
    Content-Type: application/json
    Transfer-Encoding: chunked
    Connection: keep-alive
    Strict-Transport-Security: max-age=31536000
    Set-Cookie: box_visitor_id=61500abdc35992.86993060; expires=Mon, 26-Sep-2022 05:53:01 GMT; Max-Age=31536000; path=/; domain=.box.com; secure
    Set-Cookie: bv=OPS-44737; expires=Sun, 03-Oct-2021 05:53:01 GMT; Max-Age=604800; path=/; domain=.app.box.com; secure
    Set-Cookie: cn=26; expires=Mon, 26-Sep-2022 05:53:01 GMT; Max-Age=31536000; path=/; domain=.app.box.com; secure
    Set-Cookie: site_preference=desktop; path=/; domain=.box.com; secure
    Cache-Control: no-store

    {"error":"invalid_grant","error_description":"Auth code doesn't exist or is invalid for the client"}


    Not sure what's wrong here..! Can you please advise me on this?

    Thanks,

    Nitesh

    0
    Comment actions Permalink
  • Nitesh Singhal

    Ok I was able to fix this but now struggling with downloading the latest file from the folder as download API needs the <file id> and it will change everytime when the new files are pushed to Box.

    And I need to do it all via Ansible only.

    0
    Comment actions Permalink

Please sign in to leave a comment.