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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.