Multiple sends through MessageDefinitionSends

Is there currently a way to batch triggered send requests through the REST API? All I’m finding in the documentation is triggering one at a time.

Code Sample (removing the array and only sending one element works as expected):

fuel({
        method: 'POST',
        url: 'https://www.exacttargetapis.com/messaging/v1/messageDefinitionSends/key:33/send',
        json: true,
        body: [{
                From:{
                    Address:"myFromAddress@domain.com",
                    Name:"David"
                },
                To:{
                    Address:"myemail_1@domain.com",
                    SubscriberKey:"myemail_1@domain.com",
                    ContactAttributes:{
                        SubscriberAttributes:{
                                CusField1:"My Custom Field 1",
                                CusField2:"My Custom Field 2",
                                CusField3:"My Custom Field 3"
                            }
                    }
                }
            },{
                From:{
                    Address:"myFromAddress@domain.com",
                    Name:"David"
                },
                To:{
                    Address:"myemail_2@domain.com",
                    SubscriberKey:"myemail_2@domain.com",
                        ContactAttributes:{
                            SubscriberAttributes:{
                                CusField1:"My Custom Field 1",
                                CusField2:"My Custom Field 2",
                                CusField3:"My Custom Field 3"
                            }
                        }
                    }
        }]  
    }, function (error, request, body) {
        console.log("response: " + JSON.stringify(body));
    });

console: < response: {“message”:”Problem initating message send during deserialization of JSON payload.”,”errorcode”:10004,”documentation”:””}

I have tried different variations of the above code like sending just the “To” section as an array and encapsulating the array in parent brackets. I used fuel for ease of example, but the same error can be achieved in Postman.

Answer

Batch them by sending in as an array to

https://www.exacttargetapis.com/messaging/v1/messageDefinitionSends/key:{your key}/sendBatch

[{
    "From": {
        "Address": "code@exacttarget.com",
        "Name": "Code@"
    },
    "To": {
        "Address": "example@example.com",
        "SubscriberKey": "example@example.com",
        "ContactAttributes": {
            "SubscriberAttributes": {
                "Region": "West",
                "City": "Indianapolis",
                "State": "IN"
            }
        }
    }
}, {
    "From": {
        "Address": "code@exacttarget.com",
        "Name": "Code@"
    },
    "To": {
        "Address": "example2@example.com",
        "SubscriberKey": "example2@example.com",
        "ContactAttributes": {
            "SubscriberAttributes": {
                "Region": "East",
                "City": "Indianapolis",
                "State": "IN"
            }
        }
    }
}]

Attribution
Source : Link , Question Author : David , Answer Author : Kelly J Andrews

Leave a Comment