Discussions
REST API put updates are not being written to Change History
6 days ago by Andrew Tang
Hello,
I was making a put request as follows for the Name Table. Below is a sample of my request on the client side.
const config = {
baseUrl: `${window.location.protocol}//${window.location.host}/imis_dev`,
requestVerificationToken: document.getElementById("__RequestVerificationToken").value,
};
async function updateMemberType(memberId, newMemberType) {
const response = await fetch(`${config.baseUrl}/api/Name?PartyId=${memberId}`, {
method: 'GET',
headers: {
"Content-Type": "application/json",
"RequestVerificationToken": config.requestVerificationToken,
},
});
if (!response.ok) {
throw new Error(`Failed to fetch member data: ${response.statusText}`);
}
let memberData = await response.json();
if (memberData.Items && memberData.Items.$values && memberData.Items.$values.length > 0) {
memberData = memberData.Items.$values[0];
}
if (memberData.Properties && memberData.Properties.$values) {
const memberTypeProp = memberData.Properties.$values.find(prop => prop.Name === "MEMBER_TYPE");
if (memberTypeProp) {
memberTypeProp.Value = newMemberType;
}
}
const updateResponse = await fetch(`${config.baseUrl}/api/Name/${memberId}`, {
method: 'PUT',
headers: {
"Content-Type": "application/json",
"RequestVerificationToken": config.requestVerificationToken,
},
body: JSON.stringify(memberData)
});
if (!updateResponse.ok) {
throw new Error(`Failed to update member: ${updateResponse.statusText}`);
}
}
updateMemberType("332002", "INDIV");
And I get this response:
I checked the data, and everything was updated properly. However, it does not show up in the changelog for some reason, even though it writes properly when this is updated manually. I also know that the Name table's Member_Type property is tracked by default.
The version of iMIS that is being used is 20.2.66.1385.
Let me know if there is something I am missing. Thanks.