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

Announcements

News and Announcements icon
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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 542 Most Valuable Professional

#2
Haque Profile Picture

Haque 206

#3
Kalathiya Profile Picture

Kalathiya 201 Super User 2026 Season 1

Last 30 days Overall leaderboard