web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Use of Power pages Web...
Power Apps
Unanswered

Use of Power pages Web API in PCF control

(0) ShareShare
ReportReport
Posted on by 2

Hi,

 

We have developed the PCF control for Power Pages and integrated it onto the relevant pages. However, we now have a requirement from the customer that necessitates the utilization of the Power Pages Web API. Upon attempting to incorporate the code available at the link provided below, we encountered an issue.

 

https://learn.microsoft.com/en-us/power-pages/configure/write-update-delete-operations#wrapper-ajax-function

 

We are encountering an issue with the code below.

 

 

(function (webapi, $) {

    function safeAjax(ajaxOptions:any) {

        var deferredAjax = $.Deferred();

 

        shell.getTokenDeferred().done(function (token:any) {

            // add headers for AJAX

            if (!ajaxOptions.headers) {

                $.extend(ajaxOptions, {

                    headers: {

                        "__RequestVerificationToken": token

                    }

                });

            } else {

                ajaxOptions.headers["__RequestVerificationToken"] = token;

            }

            $.ajax(ajaxOptions)

                .done(function (data, textStatus, jqXHR) {

                    validateLoginSession(data, textStatus, jqXHR, deferredAjax.resolve);

                }).fail(deferredAjax.reject); //AJAX

        }).fail(function () {

            deferredAjax.rejectWith(this, arguments); // on token failure pass the token AJAX and args

        });

 

        return deferredAjax.promise();

    }

    webapi.safeAjax = safeAjax;

})(window.webapi = window.webapi || {}, jQuery)

 

Does anyone have sample code demonstrating how to utilize the Power Pages Web API within a PCF control.

 

Thanks!

I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
Kalathiya Profile Picture

Kalathiya 419

#2
WarrenBelz Profile Picture

WarrenBelz 397 Most Valuable Professional

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 345 Super User 2025 Season 2

Last 30 days Overall leaderboard