Greetings everyone. I am trying to create a record in Dataverse from PowerApps portals using Web API. Since these calls are async in nature, I put my code in try and catch the block to capture the error. Still, unable to capture the error. In the console, I can still error related to the web API call made. Any references or inputs are appreciated, thank you!
try
{
var record = {};
record["xxxxxx"] = "DAta";
webapi.safeAjax({
type: "POST",
contentType: "application/json",
url: "/_api/xxxxxxx",
data: JSON.stringify(record),
success: function (data, textStatus, xhr)
{
var newId = xhr.getResponseHeader("entityid");
console.log(newId);
$("#txtShowMessage").text("Record is successfully created.");
$('#Modal').modal('show');
},
error: function (xhr, textStatus, errorThrown)
{
console.log(xhr);
}
});
}
catch(error)
{
$("#txtShowMessage").text("Sa");
$('#Modal').modal('show');
}