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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
dpzafra
New Member

Call API in a Custom Visual not working

I build a custom visual that call a external api with a interval, this is the code:

 

const response = await fetch("http://localhost:3000",{
            method: 'POST',
            headers: {
            'content-type': 'application/json;charset=UTF-8',
            },
            body: JSON.stringify({
                data: column_id
            }),
        });
 
Also add in capabilities.json :
    "privileges": [
        {
            "name": "WebAccess",
            "essential": true,
            "parameters": ["http://localhost:3000"]
        }
 
It works in development mode, but when i build and package the solution it doesn´t in powerbi desktop. 
 
The api is program in node with cors enable and listening in port 3000, http:
app.use(cors({
    origin: '*'
}));
 
Thank you for your help.
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @dpzafra ,

There are a few areas we need to review to troubleshoot the issue effectively:
1. CORS Configuration: Since your API is set up to accept requests from any origin (origin: '*'), this should generally not be the issue. However, it's worth ensuring that your Node server's CORS configuration is correctly implemented and that there are no additional security measures in place that might block requests when your visual is not in development mode.
2. Power BI Desktop Environment: Power BI Desktop might have different security and execution environments compared to the development mode. Ensure that your Power BI Desktop is up to date. Although not directly related, keeping your software updated can sometimes resolve unexpected issues.
3. Network Configuration: Verify that there are no network issues or firewalls blocking the request from Power BI Desktop to your local server. This is a common issue when moving from a development environment to a more restricted execution environment like Power BI Desktop.
4. Debugging the Issue: To further diagnose the problem, it would be helpful to know if there are any error messages or codes returned when the request fails. Additionally, checking the network activity using tools like Fiddler or the network tab in browser developer tools (if testing in Power BI Service) can provide insights into what might be going wrong.

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
dpzafra
New Member

Thank you Dino, include:

app.use(cors({
    origin: '*'
}));
and it works.
 
Anonymous
Not applicable

Hi @dpzafra ,

There are a few areas we need to review to troubleshoot the issue effectively:
1. CORS Configuration: Since your API is set up to accept requests from any origin (origin: '*'), this should generally not be the issue. However, it's worth ensuring that your Node server's CORS configuration is correctly implemented and that there are no additional security measures in place that might block requests when your visual is not in development mode.
2. Power BI Desktop Environment: Power BI Desktop might have different security and execution environments compared to the development mode. Ensure that your Power BI Desktop is up to date. Although not directly related, keeping your software updated can sometimes resolve unexpected issues.
3. Network Configuration: Verify that there are no network issues or firewalls blocking the request from Power BI Desktop to your local server. This is a common issue when moving from a development environment to a more restricted execution environment like Power BI Desktop.
4. Debugging the Issue: To further diagnose the problem, it would be helpful to know if there are any error messages or codes returned when the request fails. Additionally, checking the network activity using tools like Fiddler or the network tab in browser developer tools (if testing in Power BI Service) can provide insights into what might be going wrong.

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.