Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
LasseL
Helper I
Helper I

Getting Refused to connect to X because it violates the following Content Security Policy directive

Dear community,

 

On a custom visual I am trying use a http post request by fetch to a logic app endpoint, and getting following error from the Console:

 

Refused to connect to 'https://xxx.logic.azure.com/xxx' because it violates the following Content Security Policy directive: "default-src 'self' data: blob: 'unsafe-inline' 'unsafe-eval'". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.

 

Following is the code from the react component of the visual:

    handleClick = () => {

        fetch('https://xxx.logic.azure.com:443/xxx', {  
        method: 'POST',
        mode: 'cors',
        body: JSON.stringify({"Data": {"Text1": "Test5", "Text2": "Test6"}}) // body data type must match "Content-Type" header
       })
 
 
For which reason I have tried to add to capabiltities.json the following:
     "privileges": [
        {
            "name": "WebAccess",
            "essential": true,
            "parameters": [ "https://prod-23.northeurope.logic.azure.com/", "https://*.logic.azure.com/", "https://prod-23.northeurope.logic.azure.com:443/", "*.logic.azure.com:443/" ]
        },
        {
            "name": "ExportContent",
            "essential": true
        }
    ]
}
 
Anyone got some ideas? Is it at all possible to do http request from a visual or has it been entirely blocked out by MS on the Power BI service?
 
Best regards and thanks
23 REPLIES 23
pbn
Frequent Visitor

You got a 200 back. That's great.
So what exactly is your challenge?

 

The only think to do is to set the whitelisted web-urls in capabilities.json "privileges". Your own servers and all of the microsoft services as well.

Hi @pbn ,

 

The 200 I got back was a test with another visual from appsource, demonstrating that it is indeed possible to use fetch requests within custom visuals and sandboxed iframe.

 

You are very right, it was just a question of getting the privileges set right it terms of whitelisting, when I got the servers in the requests went straight through!

 

Thanks, I do not seem to find an actual answer that I can accept from you, can you provide one? 😉

 

Have a great day.

pbn
Frequent Visitor

I really want to help you if I can. However, I don't understand your question. Where is your knowledge gap?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.