Cannot read a file attached in another App; 403 Error

Hello everyone,

I want to read and modify a .docx file that is in a Attachment field in another App.

I know it is saved as a file.json, and I got fileKey of this file.

But I cannot access the file.json of another App as it results in a 403 error.

To solve this, I gave full permission like this:

App Permissions:

Failed attempt to get the file.json file:

Resulting 403 Forbidden Error

This is my code:
:zap: Note url variable is hardcoded with {subdomain} & AppID

(function () {
  'use strict';
  var mergeDocumentEvents = ['app.record.edit.submit', 'app.record.create.submit'];, function (event) {
    var lookupID ='Doc_lookup');
    var recordID = event.record['Doc_lookup'].value;
    // console.log("Template App ID:",text,"Lookup code",event.record['Doc_lookup']);
    var docBody = {
      'app': lookupID,
      'id': recordID
    console.log("currentLookupId", lookupID, "currentRecordId", recordID);
    kintone.api(kintone.api.url('/k/v1/record', true), 'GET', docBody, function (resp) {
      var fileKey = resp.record.Attachment.value[0].fileKey;
      var url = 'https://{subdomain}' + fileKey;
      console.log("fileurl", url);
      var xhr = new XMLHttpRequest();'GET', url);
      xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
      xhr.responseType = 'blob';
      xhr.onload = function () {
        if (xhr.status === 200) {
          // success
          var blob = new Blob([xhr.response]);
          var windowUrl = window.URL || window.webkitURL;
          var blobUrl = windowUrl.createObjectURL(blob);
          console.log("bloburl-----", blobUrl);
        } else {
          // error
    }, function (error) {
      // error

Please help me.

Hello @unudeveloper ,

This is most likely because the URL specified for download files is incorrect.

The URL needs to be:


  • https://{subdomain}

instead of


So it needs to be:

var url = 'https://{subdomain}' + fileKey;

Download File API - Kintone Developer Program

Could you try this and see if it works?

1 Like

Thank you, I will try it.

Thanks Chris.
It works well.
Best Regards.