Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
I have been trying to embed a Power BI report into a flask website using the embed for customers tutorials. When I attempt to load the report on the website, requests named 'conceptualschema?userPreferredLocale=en-US' and 'modelsAndExploration?preferReadOnlySession=true' are being blocked by CORS errors. This is the request url in front of both requests: 'https://wabi-us-gov-virginia-redirect.analysis.usgovcloudapi.net/explore/reports/c5fe6639-c22d-4bd5-.... We have tried setting the header 'Access-Control-Allow-Origin' to a wildcard(*) on the initial request, but the header is only applied to the first request made. Has anyone run into this problem before?
Hi @taylorjboone,
Please review the following thread which has similar problem as yours, hope it can help you resolve the problem...
CORS is a browser security feature that disallows cross site referencing. Hence there isn't any setting on the PowerBI part to get it fixed. We earlier worked with the REST APIs but faced CORS issue on almost every browser. Using the CORS plugin for Chrome fixed the issue. But can't expect every user to install the client side plugi...As a work around, we took the WebAPI approach, wherein our client side script hit the WebAPI endpoint, communicated with the PowerBI service to return the report. To overcome the CORS issue this way, add a reference to System.Web.Cors in the WebConfig.cs file found under App_Start folder and add the line
config.EnableCors();
In the Controller, decorate the method with EnableCors as shown below and that should resolve your problem:
namespace MyNameSpace.MyControllers { public class MyAPIController : ApiController { [HttpPOST] [EnableCors(origins: "*", headers: "*", methods: "*")] public string getData() { return "This Works !"; } } }
Best Regards
Would you happen to know how to do this in flask (python)? I haven't been able to find a file analogous to WebConfig.cs.