Update a Data Extension with a Null Field Value

After assigning a value to a nullable field within a data extension, it may be necessary to return that field to a null value. When a call doesn’t provide a value for a field in an update request, that field retains the current value. To overwrite the value of a field with a null value, the call must explicitly state that null value using the NullAPIProperty type.

Use these code examples to update a nullable field in a data extension to a null value.

Sample .NET Code 

1private void UpdateDEFieldToNull()
2{
3    SoapClient MCSOAPClient = new SoapClient();
4    MCSOAPClient.ClientCredentials.UserName.UserName = "XXXXX";
5    MCSOAPClient.ClientCredentials.UserName.Password = "XXXXX";
6    string requestID;
7    string status;
8    DataExtensionObject DEO = new DataExtensionObject();
9    DEO.CustomerKey = "ExampleDE";
10    APIProperty EmailProperty = new APIProperty();
11    EmailProperty.Name = "EMAIL";
12    EmailProperty.Value = "example@example.com";
13    APIProperty NumberProperty = new NullAPIProperty();
14    NumberProperty.Name = "NumberField";
15    DEO.Properties = new APIProperty[] { EmailProperty, NumberProperty };
16    UpdateResult[] cresults = MCSOAPClient.Update(new UpdateOptions(), new APIObject[] { DEO }, out requestID, out status);
17    foreach (UpdateResult result in cresults)
18    {
19        Console.WriteLine(result.StatusMessage);
20    }
21    Console.WriteLine(requestID + ": " + status);
22}

Sample SOAP Envelope 

1<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
2   <soap:Header>
3      <wsse:Security soap:mustUnderstand="1">
4         <wsse:UsernameToken>
5            <wsse:Username>XXXXX</wsse:Username>
6            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">XXXXX</wsse:Password>
7         </wsse:UsernameToken>
8      </wsse:Security>
9   </soap:Header>
10   <soap:Body>
11      <UpdateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
12         <Options/>
13         <Objects xsi:type="DataExtensionObject">
14            <CustomerKey>ExampleDE</CustomerKey>
15            <Properties>
16               <Property>
17                  <Name>EMAIL</Name>
18                  <Value>example@example.com</Value>
19               </Property>
20               <Property xsi:type="NullAPIProperty">
21                  <Name>NumberField</Name>
22               </Property>
23            </Properties>
24         </Objects>
25      </UpdateRequest>
26   </soap:Body>
27</soap:Envelope>