DHIS2 bulk custom attribute json payload


if(typeof customAttributeString.optionSet !=='undefined' ){
  jsonPayload = JSON.stringify({
    "name": customAttributeString.name,
    "shortName": customAttributeString.shortName,
    "aggregationType": customAttributeString.aggregationType,
    "domainType": customAttributeString.domainType,
    "valueType": customAttributeString.valueType,
    "code": updateArray[i].value,
    "optionSet": {
          "id": customAttributeString.optionSet.id
      }
  });
} 
else {
  jsonPayload = JSON.stringify({
    "name": customAttributeString.name,
    "shortName": customAttributeString.shortName,
    "aggregationType": customAttributeString.aggregationType,
    "domainType": customAttributeString.domainType,
    "valueType": customAttributeString.valueType,
    "code": updateArray[i].value
  });
}

let customAttributeString = response.data;
let jsonPayload = JSON.stringify({
...customAttributeString,
"code" : updateArray[i].value,
});