Forum Discussion
LasseL
3 years agoHelper 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...
Sahir_Maharaj
3 years agoSuper User
It is not possible to make HTTP requests from a Power BI visual to an external endpoint using the Fetch API. One workaround that you could use is to have a proxy server that relays the request from the visual to the external endpoint, and this way you can avoid the CSP issue.
pbn
3 years agoFrequent Visitor
Here's a working code example. Working in all browsers and ios-App:
var xhr = new XMLHttpRequest();
var _this = this.host;
xhr.open("POST", "https://httpbin.org/post", true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(
JSON.stringify({
value: "Hello world",
})
);
xhr.onload = function () {
console.log(this.responseText);
_this.displayWarningIcon(
"Post-Request-Result",
this.responseText
);
};capabilities.json
...
"privileges": [{
"name": "WebAccess",
"essential": true,
"parameters": [
"https://httpbin.org/post", ...
]
},
...HTH
- FelipeCosta3 years agoAdvocate II
Hi, thanks, but this didn't work. I still get the same error.
Did anyone manage to make it work?
Thanks.