Skip to main content

How to call Web API and Get Data from dataverse in Power Apps Portal


Hi, the following is the steps to set up web API for Portal 

 1.) Enable Web API for a particular Table that you want to access by creating a site setting 
 eg-


2.) specify which field you want to access by this site setting
eg-


3.) create Table Permission for the table, set Privileges, and set Web Roles

eg-


4.)Use the following code to access data 
var deferredAjax = $.Deferred();
    var ajaxOptions;
    shell.getTokenDeferred().done(function(token){
       debugger;
       alert("pass")

      ajaxOptions = {
        type: "GET",
        url: "/_api/msdyn_functionallocations?$select=msdyn_name&$filter=_trbdn_customerid_value eq XXXXXXXX-xxxx-xxxx-xxxx-xxxxxxxxxxxx and statecode eq 0",
        contentType: "application/json",
        headers:{"__RequestVerificationToken":token}
      };
      // ajaxOptions.headers["__RequestVerificationToken"] = token;
       $.ajax(ajaxOptions).done(function(data, textStatus, jqXHR) {
            debugger;
            alert(data)
            validateLoginSession(data, textStatus, jqXHR, deferredAjax.resolve);

          }).fail(function (fail){
            debugger;
            alert(fail)

          });
      }).fail(function () {
      debugger;
      alert("fail")
    });





Comments