There are a bunch of customer records that need to be updated for data extension.
there is and REST API: https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/postDataExtensionRowsetByKey.html
but this API is working as follows:
Use this API to upsert multiple data extension rows. An upsert operation updates rows when the specified key already exists and inserts new rows when the specified key doesn't exist.
I need to update rows only when the primary key exists in the data extension and skip others without creating new records.
of course, I can make additional requests before the upsert operation to check which records don't exist and exclude them from the list but these are additional requests.
I'm wondering if there is a way to update records and avoid inserting new ones.
UPDATE: I found a solution by using the SOAP API instead of REST.
POST: https://<...>.soap.marketingcloudapis.com/Service.asmx
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<a:Action s:mustUnderstand="1">UpdateOnly</a:Action>
<a:To s:mustUnderstand="1">https://<...>.soap.marketingcloudapis.com/Service.asmx</a:To>
<fueloauth xmlns="http://exacttarget.com">{{token}}</fueloauth>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<UpdateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
<Options>
<SaveOptions>
<SaveOption>
<PropertyName>DataExtensionObject</PropertyName>
<SaveAction>UpdateOnly</SaveAction>
</SaveOption>
</SaveOptions>
</Options>
<Objects xsi:type="DataExtensionObject">
<CustomerKey>CustomerKeyID</CustomerKey>
<Keys>
<Key>
<Name>Email</Name>
<Value>[email protected]</Value>
</Key>
</Keys>
<Properties>
<Property>
<Name>Email</Name>
<Value>[email protected]</Value>
</Property>
<Property>
<Name>FirstName</Name>
<Value>John</Value>
</Property>
<Property>
<Name>LastName</Name>
<Value>Smith</Value>
</Property>
</Properties>
</Objects>
<Objects xsi:type="DataExtensionObject">
<CustomerKey>CustomerKeyID</CustomerKey>
<Keys>
<Key>
<Name>Email</Name>
<Value>[email protected]</Value>
</Key>
</Keys>
<Properties>
<Property>
<Name>Email</Name>
<Value>[email protected]</Value>
</Property>
<Property>
<Name>FirstName</Name>
<Value>Jane</Value>
</Property>
<Property>
<Name>LastName</Name>
<Value>Doe</Value>
</Property>
</Properties>
</Objects>
</UpdateRequest>
</s:Body>
</s:Envelope>