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
OOlashyn
MVP

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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

Top Solution Authors
Users online (3,233)