cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SumitThakran
Helper I
Helper I

Best way to consume External Rest API in PCF Control

Hi All,

 

I have built one sub grid control using Typescript and React JS in Powerapp Control Framework.

Now i want to add some action in this subgrid control . On click of these action  , it will rather fetch data from external Rest API or update or create data in external web api too.

 

So kindly suggest me what's best way to do these Rest API operations in Typescript. Also should i consume Rest API operations in Typescript or its better to consume it in DotNet Plugin and call register that plugin on click of these action buttons or is there any better approach ?

 

My Concern here is that as Typescript is deployed finally on client side . So if  i consume Rest API in Typescript and deploy this control on Powerapp environment then it will reside on Client side application not on server side like we consume rest api in DotNet class file and hence client side deployment might create security risks too.

 

Any help or suggestion would be appreciated.

 

 

Thanks

 

11 REPLIES 11

JSONP is a mechanism that returns code that includes a callback function to get around CORS - if you can't implement JSONP - then you'll need to set the server up to allow CORS requests from the domain that you are calling it from. 

CORS needs to be addressed on the service you are calling, rather than on the client calling it.

https://stackoverflow.com/questions/14221429/how-can-i-produce-jsonp-from-an-asp-net-web-service-for...

 

Hope this helps,

 

I know it's too late, but for the future reader. If you don't have much control over the external service you are using and it's returning XML and other blocking issues, your best options are:

1. Implement your calls to external service in a custom action suggested by ScottDurroww above. HTTP calls are supported (even inside a plugin).

2. If you need calls to the external service in the UI (your PCF control), I suggest you implement a function app to wrap the external service, this gives you full control over how you call the external service and you can even transform data model to whatever that's suitable for the code in that runs in the browser. One added benefit is you can store sensitive information (api keys?) securely on Azure Function (or Key Vault).

Of courser if none of the above options are viable your last resort would be direct calls from the browser (inside your PCF control). 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Users online (4,183)