เรากำลังพยายามสร้างเอกสารใหม่ใน word online โดยใช้ไลบรารี office javascript สคริปต์มีอยู่ในคำว่า add in เอกสารประกอบสำหรับวิธีการสร้างอยู่ที่ https://dev.office.com/reference/add-ins/word/application การเรียกเอกสารที่สร้างขึ้นตามด้วยวิธีการเปิดจะส่งผลให้เกิดข้อผิดพลาดที่ต้องห้าม 403 เสมอ
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 การสร้างเอกสารจากอินเทอร์เฟซใช้งานได้
เหตุใดข้อผิดพลาดนี้จึงถูกส่งกลับ
อัปเดต
ข้อผิดพลาดเกิดขึ้นเฉพาะเมื่อมีการใช้การเพิ่มในบริบทของบัญชี Office 365 Business ที่ได้รับการสนับสนุนโดยเซิร์ฟเวอร์ sharepoint แบบออนไลน์
เมื่อฉันลองใช้บัญชี OneDrive ส่วนตัว การสร้างเอกสารและการเปิดทำได้สำเร็จ