Hi All,
Is it possible to consume the Dataverse custom API (unbound) from within Power Portals using JS? If so, please share a sample code for the same.
Thanks in advance!
Regards,
Sahil
Solved! Go to Solution.
You wont be able to call Custom API directly. If you want to consume the Custom API/Custom Action then there are other options.
You can call a Flow, which executes the Custom API, or you can set up a Companion API. I prefer the Companion API approach as its secure - https://docs.microsoft.com/en-us/power-apps/maker/portals/oauth-implicit-grant-flow
You dont want to expose ClientId/Secret in Javascript.
You cant consume it from Portal, however you can implement the Portal API.
https://docs.microsoft.com/en-us/power-apps/maker/portals/web-api-overview
You cant consume it from Portal, however you can implement the Portal API.
https://docs.microsoft.com/en-us/power-apps/maker/portals/web-api-overview
Hi, I have gone through this documentation already but could not find any details on how to call Dataverse Custom APIs from within Power Portal.
Some Background details:
I created a Custom API record in Dataverse and associated a plugin to the same API. Now, I need to call this API from Portal with some Input Parameters in the request and get output parameters as the response.
I saw this post that talks about how to call custom actions from Portal and we get a custom action for a Custom API as well so shouldn't we be able to consume the APIs in the same way from Portal?
https://debajmecrm.com/call-custom-action-using-webapi-in-powerapps-portals-dynamics-365-portals/
You wont be able to call Custom API directly. If you want to consume the Custom API/Custom Action then there are other options.
You can call a Flow, which executes the Custom API, or you can set up a Companion API. I prefer the Companion API approach as its secure - https://docs.microsoft.com/en-us/power-apps/maker/portals/oauth-implicit-grant-flow
You dont want to expose ClientId/Secret in Javascript.
Custom Actions via the Portal API was on the roadmap - not sure where it is at in terms of when its in public preview
Hi,
Based on my analysis/hits and tries so far, I am able to call any custom action and custom API that is bound to the CONTACT entity from Power Portals. But, I am still not able to get the response/output parameters from the API call if it is a success. The below syntax works:
webapi.safeAjax({
type: "POST",
url: "/_api/contacts("ENTER GUID")/Microsoft.Dynamics.CRM.new_contactapi",
contentType: "application/json",
data: JSON.stringify({ "name": "Test" }),
success: function (res, status, xhr){
}
});
I have done similar but yes as long as its bound action, if unbound then an issue. Did you check the response header for any output?
Yea, I tried to check the Response Header in the developer console but nothing is there. However, if you try to create a new record using the Portal API then you get the ID (entityid) of the record in the response header.
I believe that maybe the Power Automate flow (with HTTP trigger) might be an option for me as I need the response parameters back to navigate the portal user accordingly (after custom logic) to the next screen.