0

I have the following 'To' object in an API request:

"To": {
        "Address": "email address here",
        "SubscriberKey": "Subscriber key here",
        "ContactAttributes": {
            "SubscriberAttributes": {
                "EmailAddress":"Email address here",
                "SubscriberKey": "Subscriber key here",
                "Language": "Language here",
                "Country": "Country here"
            }
        }
    }

What I am wondering is; how can I add values to the inline objects "ContactAttributes" and "SubscriberAttributes" with AMPscript?

I know that I can set values for the 'To' object with the SetObjectProperty function:

 SET @ts_to = CreateObject("To")
    SetObjectProperty(@ts_to, "Address", @EmailAddress)
    SetObjectProperty(@ts_to, "SubscriberKey", @SubscriberKey)

But I get stuck with these inline objects.

1 Answer 1

0

Only Address and SubscriberKey are required, the rest go under SubscriberAttributes. The SubscriberAttributes node should not include the Email Address or Subscriber Key.

{
    "To": {
        "Address": "aspriggs@example.com",
        "SubscriberKey": "aspriggs@example.com",
        "ContactAttributes": {
            "SubscriberAttributes": {
                "FirstName": "Adam",
                "LastName": "Spriggs",
                "someCode": "1234",
                "HTML__payload": "<h1>Whee!</h1>"
            }
        }
    } 
}

The SubscriberAttributes values correspond to the column names in your Triggered Send Data Extension columns.

Reference

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.