I have the following to update a record:
var currentTimeBeingTracked = getCurrentTimeTracked();
if (currentTimeBeingTracked != null) {
currentTimeBeingTracked.dagency_EndDateTime = new Date();
var jsonTrackedTime = window.JSON.stringify(currentTimeBeingTracked);
$.ajax({ type: "POST",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: ODataPath + "/dagency_trackedtimeSet",
data: jsonTrackedTime,
beforeSend: function (XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("Accept", "application/json");
},
success: function (data, textStatus, XmlHttpRequest) {
var newTimeTracked = data.d;
RetrieveTrackedTimes();
alert("Stopped tracking your time successfully.");
window.top.document.getElementById("contentIFrame").contentWindow.location.reload();
},
error: function (XmlHttpRequest, textStatus, errorThrown) {
debugger;
alert("Couldn't stop tracking your time. " + XmlHttpRequest.responseText);
}
});
}
But I keep getting this message:
Error processing request stream. Error encountered in converting the value from request payload for property 'CreatedOn' to type 'DateTime', which is the property's expected type. See inner exception for more detail.
To create the record, I use the following code that works perfectly:
var trackedTime = new Object();
var timeEntryName = prompt("Please enter a name for the tracked time:", "New time entry");
if (!timeEntryName) {
return false;
}
var isBillable = confirm("Is this task billable? If Yes, press OK.");
trackedTime.dagency_name = timeEntryName;
trackedTime.dagency_StartDateTime = new Date();
trackedTime.dagency_Billable = isBillable;
var slot = new Object();
slot.Id = crmForm.ObjectId;
trackedTime.dagency_Slot = slot;
var jsonTrackedTime = window.JSON.stringify(trackedTime);
$.ajax({ type: "POST",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: ODataPath + "/dagency_trackedtimeSet",
data: jsonTrackedTime,
beforeSend: function (XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("Accept", "application/json");
},
success: function (data, textStatus, XmlHttpRequest) {
var newTimeTracked = data.d;
RetrieveTrackedTimes();
alert("Started tracking your time successfully.");
window.top.document.getElementById("contentIFrame").contentWindow.location.reload();
},
error: function (XmlHttpRequest, textStatus, errorThrown) {
alert("Couldn't start tracking your time. " + XmlHttpRequest.responseText);
}
});
What is the problem? Where can I find the inner exception the message refers to?