Forum Discussion
LasseL
Helper I
3 years agoGetting 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...
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
FelipeCosta
Advocate II
3 years agoHi, thanks, but this didn't work. I still get the same error.
Did anyone manage to make it work?
Thanks.