Share via

Word Online insertComment API error NotAllowed

TJ Jann 0 Reputation points
2026-06-03T02:28:49.7633333+00:00

Inserting comments via API (in JS, Range.insertComment) was consistently working in Word Desktop but consistently failing in Word Online.

According to https://mms.heiai.top/en-us/javascript/api/word/word.range?view=word-js-preview#word-word-range-insertcomment-member(1), Range.insertComment should work, since it is API set: WordApi 1.4 which is "Supported" by " Office on the web".

To help debug, I added these diag logs:

      1461 -      // TODO(remove): temporary diagnostic for the NotAllowed error on Word Online.                                                                              
      1462 -      // Logs what the host claims about comments-API support before the call, and                                                                                
      1463 -      // captures the full documented error payload (debugInfo) if insertComment throws.                                                                          
      1464 -      debugLog(`[diag] host=${Office.context.host} platform=${Office.context.platform}`);                                                                         
      1465 -      debugLog(                                                                                                                                                   
      1466 -        `[diag] isSetSupported(WordApi,1.4)=${Office.context.requirements.isSetSupported('WordApi', '1.4')}`,                                                     
      1467 -      );

      1471 -      try {                                                                                                                                                       
      1472 -        range.insertComment(commentText);                                                                                                                         
      1473 -        await context.sync();                                                                                                                                     
      1474 -      } catch (error) {                                                                                                                                           
      1475 -        debugError(                                                                                                                                               
      1476 -          '[diag] insertComment failed; debugInfo:',                                                                                                              
      1477 -          JSON.stringify(error?.debugInfo, null, 2),                                                                                                              
      1478 -        );                                                                                                                                                        
      1479 -        throw error;                                                                                                                                              
      1480 -      } 

Which yielded

  [7:01:21 PM] [diag] host=Word platform=OfficeOnline                                                                                                                                
  [7:01:21 PM] [diag] isSetSupported(WordApi,1.4)=true                                                                                                                               
  [7:01:21 PM] [diag] insertComment failed; debugInfo: { "code": "NotAllowed", "message": "The action isn't supported by Word in a browser. Check the                                
  OfficeExtension.Error.debugInfo for more information.", "errorLocation": "Range.insertComment", "statement": "var insertComment = range.insertComment(...);",                      
  "surroundingStatements": [ "var v = context.root._getObjectByReferenceId(\"{135f5ce2-52d7-435c-8474-cb5a198e8a63}{22}\");", "var range = v.getRange();", "// Instantiate {range}", 
  "// >>>>>", "var insertComment = range.insertComment(...);", "// <<<<<", "// Instantiate {insertComment}" ], "fullStatements": [ "Please enable config.extendedErrorLogging to     
  see full statements." ] }
Microsoft 365 and Office | Development | Office JavaScript API
0 comments No comments

1 answer

Sort by: Most helpful
  1. Teddie-D 18,620 Reputation points Microsoft External Staff Moderator
    2026-06-03T04:13:11.9366667+00:00

    Hi @TJ Jann
    Please note that we're not Microsoft support, this is a user-to-user support forum. Moderators here don’t have backend access to Microsoft systems, so we can only provide technical guidance based on public resources and experiences.

    Based on the information you've shared, the behavior appears inconsistent with the documented support information. Your logs show that:

    • Office.context.requirements.isSetSupported('WordApi', '1.4') returns true, indicating that Word Online reports support for the API set that includes Range.insertComment().
    • However, the call to Range.insertComment() fails with a NotAllowed error, specifically at errorLocation: "Range.insertComment".

    Since the same code works consistently in Word Desktop but fails in Word Online, this suggests a platform-specific limitation or incomplete implementation in Word Online rather than an issue with your code.

    It’s important to note that support for a requirement set such as WordApi 1.4 does not always guarantee that every API within that set is fully implemented or enabled across all hosts. In some cases, individual APIs may be partially supported or restricted in certain environments, such as Office on the web.

    I recommend opening an issue with the Office.js team on GitHub repository where developers and contributors actively working with Office.js can share additional insights and guidance. If you open a GitHub issue, feel free to share the link here, as it may help other developers encountering similar behavior.

    References: Participating in a discussion - GitHub Docs   

    Thank you for your patience and understanding, and I’m sorry we can’t resolve this directly here. Redirecting you ensures you’ll connect with the right support team who can provide the help you need.


    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.