1 year ago
#332365

Marcos Natã Santos
Refused to connect to attachment.outlook.live.net because it violates the document's Content Security Policy
I'm trying to get attachments in Outlook Addin, but I can't because of this error. Follow the codes. Important to mention that sometimes it works and other do not. I really don't know why.
getAttachmentsAsBase64ById: (attachmentId: string, handleAttachmentsCallback) => {
Office.context.mailbox.item.getAttachmentContentAsync(attachmentId, handleAttachmentsCallback);
},
const handleAttachmentsCallback = (result: Office.AsyncResult<Office.AttachmentContent>) => {
// Parse string to be a url, an .eml file, a base64-encoded string, or an .icalendar file.
switch (result.value.format) {
case Office.MailboxEnums.AttachmentContentFormat.Base64:
// Handle file attachment.
attachmentsData[currentAttachmentsIndex].content = result.value.content;
setAttachments(attachmentsData);
currentAttachmentsIndex = null;
break;
case Office.MailboxEnums.AttachmentContentFormat.Eml:
// Handle email item attachment.
break;
case Office.MailboxEnums.AttachmentContentFormat.ICalendar:
// Handle .icalender attachment.
break;
case Office.MailboxEnums.AttachmentContentFormat.Url:
// Handle cloud attachment.
break;
default:
// Handle attachment formats that are not supported.
}
};
I'm receiving the following error below:
VM853:1 Refused to connect to 'https://attachment.outlook.live.net/owa/MSA%3A4fe28d0……com&scriptVer=20220311006.09&isDownload=true&animation=true&asDataUri=true' because it violates the document's Content Security Policy.
(anonymous) @ VM853:1
(anonymous) @ activityTrackerUtils.js:56
fetch @ activityTrackerUtils.js:53
A @ getAttachmentContentHelper.ts:89
await in A (async)
(anonymous) @ VM861:297
then @ VM861:297
importAndExecute @ VM861:297
ze @ getAttachmentContentUtil.ts:25
(anonymous) @ ReadAttachmentAdapter.ts:8
qe @ getAttachmentContent…yncApiMethod.ts:156
await in qe (async)
(anonymous) @ getAttachmentContentAsyncApiMethod.ts:61
Jt @ executeApiMethod.ts:109
(anonymous) @ EndpointRegistrator.ts:41
invoke @ osfruntime.js:19
O @ osfruntime.js:19
k @ osfruntime.js:19
VM853:1 Uncaught (in promise) TypeError: Failed to fetch
at <anonymous>:1:876
at activityTrackerUtils.js:56:7
at new Promise (<anonymous>)
at fetch (activityTrackerUtils.js:53:12)
at A (getAttachmentContentHelper.ts:89:26)
at async qe (getAttachmentContent…ApiMethod.ts:156:24)
at async getAttachmentContent…cApiMethod.ts:61:17
(anonymous) @ VM853:1
(anonymous) @ activityTrackerUtils.js:56
fetch @ activityTrackerUtils.js:53
A @ getAttachmentContentHelper.ts:89
await in A (async)
Jt @ executeApiMethod.ts:109
(anonymous) @ EndpointRegistrator.ts:41
invoke @ osfruntime.js:19
O @ osfruntime.js:19
k @ osfruntime.js:19
Has someone that had this problem that could help me?
Edited
Below are more details about the error. It seems that internally Outlook doesn't have a permission rule to send requests to "outlook.live.net".
VM1358:1 Refused to connect to 'https://attachment.outlook.live.net/owa/MSA%3A4fe28d0……com&scriptVer=20220318002.07&isDownload=true&animation=true&asDataUri=true' because it violates the following Content Security Policy directive: "connect-src blob: data: *.res.office365.com *.fluidpreview.office.net *.cdn.office.net *.services.web.outlook.com login.live.com spoprod-a.akamaihd.net shellprod.msocdn.com *.bing.com *.office.net *.office.com *.office365.com *.officeapps.live.com *.skype.com *.skypeassets.com *.spoppe.com *.onedrive.com my.microsoftpersonalcontent.com substrate.office.de *.office365-net.de *.office.de browser.pipe.aria.microsoft.com *.gateway.messenger.live.com dev.virtualearth.net *.trouter.skype.com *.trouter.io wss://*.trouter.skype.com wss://*.trouter.skype.com:443 wss://*.trouter.io:443 media.licdn.com *.facebook.com onerm.olsvc.com *.qas.binginternal.com *.qas.bing.net wss://*.qas.bing.net:443 wss://*.platform.bing.com wss://*.botframework.com:443 wss://augloop.office.com wss://*.augloop.office.com outlook.live.com graph.microsoft.com *.graph.microsoft.com graph.microsoft.de *.googleapis.com *.office.microsoft.com api.box.com api.dropboxapi.com *.users.storage.live.com www.onenote.com *.storage.msn.com asgsmsproxyapi.azurewebsites.net wss://*.pushd.svc.ms wss://*.pushs.svc.ms wss://*.pushb.svc.ms wss://*.pushp.svc.ms wss://*.svc.ms nleditor.osi.officeppe.net api.tenor.com pptservicescast.officeapps.live.com *.sharepoint-df.com *.sharepoint.com *.sharepoint.de wss://*.delve.office.com:443 wss://*.loki.delve.office.com:443 wss://*.loki.delve.office.com *.delve.office.com *.loki.delve.office.com web.vortex.data.microsoft.com *.events.data.microsoft.com *.online.lync.com *.infra.lync.com wss://*.cortana.ai *.cortana.ai fs.microsoft.com 'self' login.microsoftonline.com outlook.office365.com teams.microsoft.com *.teams.microsoft.com *.yammer.com *.svc.ms *.licdn.com o365auditrealtimeingestion.manage.officeppe.com o365auditrealtimeingestion.manage.officeppe.com:445 o365auditrealtimeingestion.manage.office.com o365auditrealtimeingestion.manage.office.com:445 files.yammerusercontent.com wss://augloop-dogfood.officeppe.com wss://*.augloop-dogfood.officeppe.com wss://augloop-gcc.office.com wss://*.augloop-gcc.office.com aesir.office.com r3.res.outlook.com *.oscs.protection.outlook.com arc.msn.com *.msedge.net".
(anonymous) @ VM1358:1
(anonymous) @ activityTrackerUtils.js:56
fetch @ activityTrackerUtils.js:53
A @ getAttachmentContentHelper.ts:89
await in A (async)
(anonymous) @ LazyAction.ts:47
Promise.then (async)
importAndExecute @ LazyAction.ts:45
Be @ getAttachmentContentUtil.ts:25
(anonymous) @ ReadAttachmentAdapter.ts:8
Je @ getAttachmentContent…yncApiMethod.ts:156
await in Je (async)
(anonymous) @ getAttachmentContentAsyncApiMethod.ts:61
Qt @ executeApiMethod.ts:97
(anonymous) @ EndpointRegistrator.ts:41
invoke @ osfruntime.js:20
O @ osfruntime.js:20
k @
outlook
outlook-addin
office-addins
outlook-web-addins
outlook-restapi
0 Answers
Your Answer