I am attempting to change the values of some existing JSON data with a PATCH request, but when sending the request, only some of the requested values are updated, not all.
PATCH Request:
function updateRequest(){
let updateOptionValuesUrl =
'https://something.something.com/v1.0/dealers/Options/289?apiKey=1234abcdefghjiklmnop';
const updateOptionValuesRequest = new XMLHttpRequest();
updateOptionValuesRequest.open('PATCH', updateOptionValuesUrl);
updateOptionValuesRequest.setRequestHeader("Accept", "text/json");
updateOptionValuesRequest.setRequestHeader("Content-Type", "text/json");
updateOptionValuesRequest.onreadystatechange = function () {
const response = updateOptionValuesRequest.response;
if (!response.response) {
console.log("updateValueStatus" + " " + updateOptionValuesRequest.status);
console.log(updateOptionValuesRequest.responseText);
}
}
updateOptionValuesRequest.send('{"platformName":"new-name","optionName": "new-name","dotDigitalId":4,"optionValue":"new-name"}');
}
Existing Data BEFORE REQUEST
{
"data": [
{
"rooftopGoogleOptionId": 289,
"googleId": 112,
"dotDigitalId": 2,
"optionName": "test-name",
"optionValue": "test-name",
"platformName": "test-name",
"googleAccount": {
"googleId": 112,
"active": false,
"viewId": 51008847,
"viewName": "www.something.com",
"credentials": "",
"vdpUrlPatterns": null,
"updatedBy": null,
"updatedAt": null,
},
}
Existing DATA AFTER Request
{
"data": [
{
"rooftopGoogleOptionId": 289,
"googleId": 112,
"dotDigitalId": 2,
"optionName": "test-name",
"optionValue": "new-name",
"platformName": "new-name",
"googleAccount": {
"googleId": 112,
"active": false,
"viewId": 51008847,
"viewName": "www.something.com",
"credentials": "",
"vdpUrlPatterns": null,
"updatedBy": null,
"updatedAt": null,
},
}
As you can see above, optionName & dotDigitalId did NOT update even though they were both in the request.