An Office service that supports add-ins to interact with objects in Office client applications.
Dear @Faizan Mohammed
Thank you for the detailed explanation. Since the first insertFileFromBase64() succeeds, I would like to narrow down whether the issue is related to the Base64 content itself or to the document state after the first insertion.
Could you please provide the following details?
- Base64 comparison
- Is the exact same Base64 string returned by your API used for both the first and subsequent insertFileFromBase64() calls?
- Could you please log the Base64 string length (rather than the full content) immediately before each call and confirm whether the length/content is identical?
- How the file is obtained
- Please confirm whether the file retrieved from the server is the original output from getFileAsync(), or whether it is decoded, converted, compressed, or otherwise processed before being returned by the API.
- If possible, please provide the relevant API response format or a sanitized sample.
- Insertion code
- Please share the smallest code sample containing:
- getFileAsync()
- the API call used to retrieve the saved file
- the Base64 conversion
- both insertFileFromBase64() calls
- Please also include the coercionType and insertLocation values used.
- Document state
- Are the two insertions performed in the same Word document/session?
- Are they performed sequentially, with context.sync() completed after the first insertion?
- Does the second insertion fail only when inserting the same file twice, or does it also fail when inserting a different valid .docx file?
- Error details
- For the "OOXML malformed" error, please provide the complete error message and error code, if available.
- If the operation fails silently, please confirm whether the returned Word.run()/Promise is resolving successfully or whether an exception is being caught elsewhere.
As an additional test, could you please try inserting the same Base64 content twice using a freshly opened blank Word document? This will help determine whether the issue is specific to the document’s state after the first insertion.
I have not yet concluded that the saved Base64/OOXML is corrupted. The fact that the first insertion succeeds makes it important to compare the exact payload and execution state between the first and second calls.
Once I have the above information and the relevant taskpane.txt code, I can help identify whether the problem is with the Base64 conversion, OOXML package, insertion location, or the Office.js document state.