Skip to main content
Navigate to microsoft.com
Power Pages
  • Capabilities
  • Pricing
    • Documentation
    • Blog
    • Support
    • Overview
    • Forums
    • Galleries
    • Ideas
    • User groups
  • Register
  • ·
  • Sign in
  • ·
  • Help
Go To
  • Microsoft Power Pages Community
  • Welcome to the Community!
  • News & Announcements
  • Get Help with Power Pages
  • General Discussions
  • Design & Build
  • Customize & Extend
  • Security
  • Administer & Monitor
  • Power Apps Portals
  • Galleries
  • Community Connections & How-To Videos
  • Webinars and Video Gallery
  • Front-end Code Samples
  • Portal-Friendly Code Component Samples
  • Portal Web API Services
  • Liquid Code Samples
  • Events
  • Community Blog
  • Power Pages Community Blog
  • Community Support
  • Community Accounts & Registration
  • Using the Community
  • Community Feedback
cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for 
Search instead for 
Did you mean: 
  • Microsoft Power Pages Community
  • Galleries
  • Portal Web API Services
  • Powerapps portal Web API Wrapper Says: Cannot set ...

Powerapps portal Web API Wrapper Says: Cannot set properties of undefined (setting 'safeAjax')

01-16-2023 03:52 AM

niccoloako
New Member
71 Views
LinkedIn LinkedIn Facebook Facebook Twitter Twitter
niccoloako
niccoloako
New Member
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

Powerapps portal Web API Wrapper Says: Cannot set properties of undefined (setting 'safeAjax')

3 weeks ago

When initialize wrapper in the header of the portal I get the following error

niccoloako_2-1673869702194.png

 

 

niccoloako_1-1673869661094.png

 

Below is the wrapper code

 

 

(function(webapi, $){
	function safeAjax(ajaxOptions) {
		var deferredAjax = $.Deferred();
		shell.getTokenDeferred().done(function (token) {
			// 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)

 

 

 

How can I fix it?

 

Thank you.

Labels:
  • Labels:
  • General
Message 1 of 1
71 Views
0 Kudos
Reply
  • All forum topics
  • Next Topic

Power Platform

  • Overview
  • Power BI
  • Power Apps
  • Power Pages
  • Power Automate
  • Power Virtual Agents

Resources

  • Documentation
  • Blog
  • Support
  • Community

  • © 2023 Microsoft
  • Privacy & cookies
  • Terms of use
  • Trademarks
California Consumer Privacy Act (CCPA) Opt-Out Icon Your California Privacy Choices