Below are the settings I have enabled
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:
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.