Forum Discussion
safalkishore
Microsoft Employee
6 years agoPower BI Visual calling into REST APIs
I am developing a sample power bi visual after following the article - https://docs.microsoft.com/en-us/power-bi/developer/visuals/custom-visual-develop-tutorial
I am trying to use the 'request' npm package on the 'visuals.ts' on the constructor and then call into a custom API like the sample code shown below:
console.log('error:', error); // Print the error if one occurred
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
console.log('body:', body); // Print the HTML for the Google homepage.
});
I encounter an error on the 'pbiviz start' phase while trying the above.
Hence trying to check if this is allowed and how I could go about looking up the build error
2 Replies
- safalkishore
Microsoft Employee
Also tried setting the library as shown on this page - https://github.com/microsoft/PowerBI-visuals/blob/master/Tutorial/ExternalLibraries.md#including-javascript-files
},"externalJS": ["node_modules/request/request.js"],Yet the error persists- safalkishore
Microsoft Employee
Try to use standard https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API