我们正在尝试使用office javascript库在线创建一个新文档 . 该脚本包含在单词add in中.create方法的文档位于https://dev.office.com/reference/add-ins/word/application . 调用createdocument后跟open方法总是会导致403 forbidden错误 .
HTTP403: FORBIDDEN - The server understood the request, but is refusing to fulfill it.
(XHR)OPTIONS - https://offline.officeapps.live.com/outage.html
Failed to load https://offline.officeapps.live.com/outage.html: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://auc-word-edit.officeapps.live.com' is therefore not allowed access. The response had HTTP status code 403.
打开文档的代码如下 .
Word.run(function (context) {
var myNewDoc = context.application.createDocument();
context.load(myNewDoc);
return context.sync()
.then(function () {
myNewDoc.open();
context.sync();
}).catch(function (myError) {
console.log(e);
})
}).catch( errorHandler });
初始context.sync()调用发生错误 .
Word Online正在保存到Office 365企业帐户 . 从界面创建文档 .
为什么会返回此错误?
Update
仅当在联机共享点服务器支持的Office 365企业帐户的上下文中使用添加时,才会发生此错误 .
当我尝试使用个人OneDrive帐户时,创建文档并打开成功 .
2 回答
我认为你试图通过一行代码实现它,并且它可以在线工作 . 请试试
这个问题似乎已经解决了 . 我现在可以创建并打开一个文档 . 我只能假设它是sharepoint的临时问题或javascript库中的问题 .
感谢那些试图提供帮助的人 .