cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vduggineni91
New Member

Powerapps portal Web API Wrapper Says ( shell is not defined)

Below are the settings I have enabled 

vduggineni91_0-1645657974400.png

Below is  the web template code 

 

 

 

 

{% block main %}
<script>

	(function(webapi, $){
		function safeAjax(ajaxOptions) {
			var deferredAjax = $.Deferred();
	
			shell.getTokenDeferred().done(function (token) {
				// add headers for AJAX
				console.log(token);
				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)
	
 webapi.safeAjax({
		type: "POST",
		url: "/_api/efms_tests(7b79057b-e694-ec11-b400-0022480b3658)/Microsoft.Dynamics.CRM.efms_customapi",
		contentType: "application/json",
		data: JSON.stringify({
			"efms_in": "testing"
		}),
		success: function (res, status, xhr) {
			console.log(res)
		},
         error: function(xhr, textStatus, errorThrown) {
       console.log(errorThrown);
    }
	});


  </script>
{% endblock %}

 

 

 

Error:

 

vduggineni91_0-1645658641062.png

 

 

1 REPLY 1

Hi @vduggineni91 ,

Check my reply in this thread - https://powerusers.microsoft.com/t5/Power-Apps-Portals/shell-is-not-defined-in-web-api-update/m-p/14.... If the issue is reproducible after the portal restart and on the clean web template you would need to open a support ticket with Microsoft. 

----------------------------------------------------
If you find this post helpful consider marking it as a solution to help others find it.

Helpful resources

Announcements
Carousel Community Blog

Check out the Community Blog

Read all about the most recent blogs in the community!

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Carousel News & Announcements

What's New in the Community?

Check out the latest News & Events in the community!

Users online (4,242)