I need help with this problem, i am using javascript to create registries in a dataverse entity, the creation its ok, but the response is 204 not content... i have been reading a lot of forums and questions, all of them said that i need to put Prefer: return=representation as a request header, i already put that header but the response is the same... i know that the response header odata has the id of the created item, but i need other information...
(function (webapi, $) {
function safeAjax(ajaxOptions) {
var deferredAjax = $.Deferred();
// Obtener el token y luego hacer la solicitud
shell.getTokenDeferred().done(function (token) {
// Agregar el token a las cabeceras
if (!ajaxOptions.headers) {
ajaxOptions.headers = {
"__RequestVerificationToken": token,
"Prefer": "return=representation" // Añadir Prefer aquÃ
};
} else {
ajaxOptions.headers["__RequestVerificationToken"] = token;
ajaxOptions.headers["Prefer"] = "return=representation"; // Añadir Prefer aquà también
}
// Ejecutar la solicitud AJAX
$.ajax(ajaxOptions)
.done(function (data, textStatus, jqXHR) {
// Validar sesión o cualquier lógica necesaria
validateLoginSession(data, textStatus, jqXHR, deferredAjax.resolve);
})
.fail(deferredAjax.reject);
}).fail(function () {
// En caso de fallo al obtener el token
deferredAjax.rejectWith(this, arguments);
});
return deferredAjax.promise();
}
// Exponer la función safeAjax
webapi.safeAjax = safeAjax;
})(window.webapi = window.webapi || {}, jQuery);
const response = await webapi.safeAjax({
type: "POST",
url: "/_api/cr9c9_tbl_solicituds",
contentType: "application/json",
data: JSON.stringify(dataSolicitud)
});