Showing results for 
Search instead for 
Did you mean: 
Helper II
Helper II

How to consume Dataverse Custom API from Power Portals?

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!





@Sahil wrote:


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.

Just be aware that the url for the Flow's HTTP trigger can be called publicly by default (i.e. you may need to add security to it).  Alternatively use the Portals Implicit Grant Flow

Right. We may use Azure APIM to make it secure. Not aware of Portal Implicit Grant Flows, will explore it. Thank you for sharing 🙂



Is there any other documentation available that you are aware of Companion API or Implicit Grant Flow configuration for Portals and can share? The existing MS docs seems little confusing to me.

Resolver III
Resolver III


I have a companion app template here:
GitHub - eugenevanstaden/d365-portal-companion-api: Sample API demonstrating how to configure OAuth ...

Once you have the API set up you can consume it from the portal securely by first getting the Auth token and then executing your call to the API endpoint. I use this for custom document upload, payment integration or any secured external service that needs to be consumed from the portal.

the authUrl would be: portal/_services/auth/token?client_id=abc123
The companionAppUrl would be your endpoint.

        $("#checkout-btn").click(function () {
            $.ajax({ method: "POST", cache:false, url: "{{authUrl}}", })
                .done(function (token) {
                        method: "GET",
                        headers: { 'Authorization': "Bearer " + token },
                        url: '{{companionAppUrl}}/payment/request?orderid={{orderid}}'
                    }).done(function (data) {
                        window.location.href = data.paymentUrl; //redirect to payment page
                    }).fail(function (error) {

The MS examples are here:

May I request you to elaborate or point to an article  or link on how you can call a custom API using the Portal Web API. 

I have used the portal web api like shown below but I feel I missing key steps in using that and calling a custom API.


{% editable snippets 'GDS/APIButtonContinue' %}

{% assign entity = 'new_hsdemos' %}
{% assign fieldLogicalName = 'new_location' %}
{% assign linkPage = 'welcome' %}

{% include 'API -- WrapperAJAX' %}


// update
function updateRecord(dynid) {
const recordUrl = window.location.href;
const recordId = recordUrl.split("=")[1];
type: "PATCH",
url: "/_api/{{ entity }}(" + recordId + ")",
contentType: "application/json",
data: JSON.stringify({
"{{ fieldLogicalName }}": 100000000
success: function (res, status, xhr) {
//Button Click
$('#ButtonContinue').click(function () {


Portal Web Api details here

Have you configured the Site Settings and set up the Table and Column permissions?

The above scenario is for consuming an external api securely using the Implicit Grant flow feature from Portal. Your code sample is for consuming the Portal Web Api.

What errors are you getting?

Regular Visitor



Thank you for your response. I believe I had misunderstood the use of portal api. I now understand to call the custom dataverse API you do need the Implicit Grant flow feature from Portal and use a companion api. 

Thank you for response and clarification



There are couple of workarounds we can use to achieve this until the feature is supported in the product.

1. Create a HTTP triggered power automate and call the D365 Custom API from within the flow. Next, call the flow from the PowerApps portal client code.

2. This is an alternate way we tried using Virtual Entity. Configure a virtual entity to contain the same parameters as your Custom API input and output parameters. The Virtual entity Provider expects a plugin configured which in our case would be a Retrieve/RetrieveMultiple plugin configured on the virtual entity. The idea being when a GET call is made on the virtual entity (using REST API), the plugin would get called. The plugin will call your custom API internally and can return the output back. The good part is the RetrieveMultiple plugin gets registered as a Main event in the pipeline instead of as a POST event. Also, as compared to the first approach, you no longer have to maintain the flow URL which can also have security concerns having the signature in it.

Thanks @tappu02 .


This seems to be a good alternative. I will try to use this somewhere in my project.

Helpful resources

Carousel Community Blog

Check out the Community Blog

Read all about the most recent blogs in the community!

Carousel News & Announcements

What's New in the Community?

Check out the latest News & Events in the community!

Users online (3,270)