1

When calling insertFileFromBase64 in word online (build 16.0.12719.32656), the following error will be thrown when trying to insert some documents:

Full error object: “RichApi.Error: Cannot read property 'ha' of null at new c (https://appsforoffice.microsoft.com/lib/1/hosted/word-web-16.00.js:24:293287) at b.f.processRequestExecutorResponseMessage (https://appsforoffice.microsoft.com/lib/1/hosted/word-web-16.00.js:24:353940) at https://appsforoffice.microsoft.com/lib/1/hosted/word-web-16.00.js:24:352045“.

The actual content of the document is inserted, but any subsequent calls to insertFileFromBase64 throw “The action isn’t supported by Word in a browser," and the document content is not inserted.

The same documents can be inserted using the same logic in any word desktop client.

I'm wondering what is different in word online that could cause this error to be thrown, and how it should be handled to prevent future calls from failing to insert document content?

Here is the code I'm using to insert the document:

Word.run(async (context: Word.RequestContext) => {
        const sections = context.document.sections;
        sections.load();
        await context.sync();
        sections.items.forEach(function(section) {
          // Clear the Body.
          section.body.clear();

          // Clear any Headers.
          section.getHeader('Primary').clear();
          section.getHeader('FirstPage').clear();
          section.getHeader('EvenPages').clear();

          // Clear any Footers.
          section.getFooter('Primary').clear();
          section.getFooter('FirstPage').clear();
          section.getFooter('EvenPages').clear();
        });
        await context.sync();
        context.document.body.insertFileFromBase64(base64EncodedDocument, 'Start');
        return context.sync();
      }).catch(e => {
        console.log(e.message);
      });

Here is an example of a document that throws this error when inserted in office online: https://www.dropbox.com/s/k25ppswzxanb7ez/ASP%20clauses%20non%20admin%20test.docx?dl=0

Here is the full e.debugInfo object: e.debugInfo

Chris Nady
  • 23
  • 5

1 Answers1

0

We don't support all kinds of ContentControls now on WordOnline. And if there's any unsupported ContentControls in document, we will block latter insert file from base64 operations. This is why you can't do subsequent insertFileFromBase64, the error message is an expected one. We may gradually support more ContentControl types but i don't have a clear date yet.

And about the Cannot read property 'ha' of null , it is not right, we'll take a look, but seems so far it doesn't impact latter API calls, and it's not related to the issue why you can't do subsequent insertFileFromBase64, as I described above.

Thanks for reporting the issue to us, and sorry for inconvenience we brought.
Let us know if you have further questions.

Flora Li
  • 31
  • 1
  • It looks like https://github.com/OfficeDev/office-js/issues/191 describes the issue in more detail, but essentially inline content controls are not currently supported by word online. After we insert a document which contains inline content controls, subsequent calls to insert a document fail with “The action isn’t supported by Word in a browser". – Chris Nady Mar 26 '20 at 13:41