I get a 404 error when I'm trying to download file via Box API every time.




  • cbetta

     you are currently making an API call as the enterprise (we call this a Service Account), not the user who owns the file. You will need to create a client for that user as is described here:



    コメントアクション Permalink
  • kamenashi

    Thank you so much! I solved this problem with your teaching!!


    ...but, I got a new error :_(


    At first, the corrected code is here:

    class BoxFileDownload extends ApiActor with ActorLogging {
    	def receive: PartialFunction[Any, Unit] = {
    		case _event: HttpRequestEvent => implicit val event: HttpRequestEvent = _event
    			// Load the configuration file of the BOX application
    			val boxConfig = tryWith(getClass.getClassLoader.getResourceAsStream(SharedConf.planning.boxConf)) { boxConf =>
    				BoxConfig.readFrom(new InputStreamReader(boxConf))
    			// Set a cache information
    			val MAX_CACHE_ENTRIES = 100
    			val accessTokenCache  = new InMemoryLRUAccessTokenCache(MAX_CACHE_ENTRIES)
    			// Generate an enterprise connection object of  Box Application
    			val USER_ID = SharedConf.planning.boxUserId
    			val api     = new BoxDeveloperEditionAPIConnection(USER_ID, DeveloperEditionEntityType.USER, boxConfig, accessTokenCache)
    			// Download the Box file
    			val boxFileId = event.endPoint.getQueryString("box_file_id").getOrElse(0)
    			val file      = new BoxFile(api, boxFileId.toString)
    			val info      = file.getInfo()
    			val tmpFile   = File.createTempFile("box-", "-download")  // 一時ファイル
    			val stream    = new FileOutputStream(tmpFile)
    			log.debug(s"box download file = ${tmpFile.getPath()}")
    			mkFileDownloadViewFromStream(info.getName, new FileInputStream(tmpFile))

    Next, the error is:

    com.box.sdk.BoxAPIResponseException: The API returned an error code [403 | p6m06xfxtnkcbelx] access_denied_insufficient_permissions - Access denied - insufficient permission
    	at com.box.sdk.BoxAPIResponse.(BoxAPIResponse.java:92)
    	at com.box.sdk.BoxJSONResponse.(BoxJSONResponse.java:32)
    	at com.box.sdk.BoxAPIRequest.trySend(BoxAPIRequest.java:579)
    	at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:354)
    	at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:329)
    	at com.box.sdk.BoxFile.download(BoxFile.java:295)
    	at com.box.sdk.BoxFile.download(BoxFile.java:283)
    	at jp.co.dac.advr.planning_web.controllers.menu.BoxFileDownload$$anonfun$receive$2.applyOrElse(Index.scala:89) = this line: file.download(stream)

    Could you lend me a hand again?

    コメントアクション Permalink
  • 0
    コメントアクション Permalink
  • kamenashi

    Thank you for replying again.

    I think I already "As-User" enable my app.




    If it's possible, Could you show me the configuration screen of the setting required in this case?


    コメントアクション Permalink
  • cbetta

    If you made a change to the permissions needed, you will need to re-approve the app at the Admin console. See https://community.box.com/t5/How-to-Guides-for-Admins/Enabling-Custom-Built-Applications/ta-p/2188 for details

    コメントアクション Permalink
  • kamenashi

    > If you made a change to the permissions needed, you will need to re-approve the app at the Admin console.

    I already re-approved my app after change to the permissions needed at the Admin console.


    Is there any other solution?

    コメントアクション Permalink
  • Jason

    Hey ,


    Could you make a ticket with us at support.box.com? Include a link to this forum thread and we'll be able to help you out.



    コメントアクション Permalink
  • PromBot-Box

    We are running into same issue. we are using oAuth2.0 connection in our App (to connect to Salesforce via Salesforce Box APIs).

    We configured the application scope as documented and also added the collaborators.  We get the access token, but when trying to access the folder (via backend API),

    we get the error 'BoxApiRequest.BoxApiRequestException: The Box API responded with a 404 : Not Found'.  Can you help?

    コメントアクション Permalink