Is there any way to have SFMC Rest API update the existing records DateTime to the current DateTime? (The Data Extension field type has it set to use the current date as the default.)
Data Extension Setup
- SubscriberKey: Text, 64, Primary Key
- Name: Text, 64, Required
- UpdatedAt: Date, Required, Default to Current
Upsert Endpoints
Code Samples
- Asynchronously Upsert Data Extension
PUT {{sfmc.rest.url}}/data/v1/async/dataextensions/key:{de.key}/rows
Payload:
{
"items": [
{
"SubscriberKey": "1234",
"Name": "John",
"UpdatedAt": ""
}
]
}
- Insert Data Extension Rows by Key
POST {{sfmc.rest.url}}/hub/v1/dataevents/key:{de.key}/rowset
Payload:
[
{
"keys": {
"SubscriberKey": "1234"
},
"values": {
"Name": "John",
"UpdatedAt": ""
}
}
]
When you go through the FTP, if you have no value for the UpdatedAt
field in the CSV; then it will automatically grab the default value current DateTime for both INSERTS
and UPSERTS
. However, the REST API does not seem to respect the same logic any longer; errors are thrown if:
- the
UpdatedAt
is not included in the payload. - the
UpdatedAt
is set to""
(empty string) in the payload. - the
UpdatedAt
is set to"Now()"
in the payload.