1

I try to send multiple message using REST to this url :

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

My json look like this :

[
{
"From": {},
"To": 
    {
        "Address": "JohnDoe@yahoo.fr",
        "ContactAttributes": {
            "SubscriberAttributes": {
                "Brand_Code": "BM",
                "Country_Code": "GB",
                "EmailAddress": "JohnDoe@yahoo.fr",
                "Email_Opt_In_Country": "GB",
                "Email_Opt_In_Date": "2019-04-04",
                "Email_Opt_In_Location": "IN PERSON STORE",
                "Email_Opt_In_Source": "CGD",
                "Email_Opt_Status": "ACTIVE",
                "Email_Preference_1": "Y",
                "First_Name": "Bmtest1",
                "Gender": "M",
                "Language_Preference": "UK_en",
                "Last_Name": "BMTEST1",
                "Original_Source_System_Name": "CGD",
                "Source_Customer_Create_Date": "2019-04-04",
                "Source_Customer_id": "U49T000000021",
                "Source_System_Name": "CGD"
            }
        },
        "SubscriberKey": "BM_EU_JohnDoe@yahoo.fr"
    }
},
{
"From": {},
"To":
    {
        "Address": "JohnDoe@yopmail.com",
        "ContactAttributes": {
            "SubscriberAttributes": {
                "Brand_Code": "BM",
                "Country_Code": "GB",
                "EmailAddress": "JohnDoe@yopmail.com",
                "Email_Opt_In_Country": "GB",
                "Email_Opt_In_Date": "2019-04-04",
                "Email_Opt_In_Location": "IN PERSON STORE",
                "Email_Opt_In_Source": "CGD",
                "Email_Opt_Status": "ACTIVE",
                "Email_Preference_1": "Y",
                "First_Name": "Bmtest2",
                "Gender": "F",
                "Language_Preference": "UK_en",
                "Last_Name": "BMTEST2",
                "Original_Source_System_Name": "CGD",
                "Source_Customer_Create_Date": "2019-04-04",
                "Source_Customer_id": "U49T000000022",
                "Source_System_Name": "CGD"
            }
        },
        "SubscriberKey": "JohnDoe@yopmail.com"
    }
}
]

It look good for me, but, i always have this message:

{"message":"Problem initating message send during deserialization of JSON payload.","errorcode":10004,"documentation":""}

I saw the other responses, but i checked everything and it seem good. when i send one message, it work perfectly, i only have this when i want to send multiple message.

Can someone help me ?

0

You need to send to each recipient with an individual Api call. Remove the array [] and make 2 api calls, 1 for each recipient, instead.

  • This is not a solution in case you want to return a list of json objects at once. – Charis Moutafidis Apr 5 at 14:13
  • This request is not attempting to return objects, it is triggering the send of an email to recipient/contact. In his request, he is attempting to trigger the send of an email to multiple contacts. The marketing cloud Api does not allow for this, so he must trigger the send individually to each contact with multiple Api calls. The 'solution' to do it all at once does not exist. – Mike Apr 5 at 14:18
  • It is possible to return a list of sObjects in json format, for example accounts. I can't see why salesforce would not allow the return a list of custom json objects. – Charis Moutafidis Apr 5 at 14:26
  • This is using the Salesforce Marketing Cloud Apis (formerly Exact Target) which is a different set of Apis than those used for Salesforce CRM. They are much less robust and allow for very specific actions only. – Mike Apr 5 at 14:28
0

Check out this link here: https://developer.salesforce.com/index.php?title=Getting_Started_with_Apex_JSON

In the Getting started, System.JSON section, there is a sample json of JSON output.

{
  "attributes" : {
    "type" : "Account",
    "url" : "/services/data/v24.0/sobjects/Account/001d000000Ard7uAAB"
  },
  "Id" : "001d000000Ard7uAAB",
  "Name" : "United Oil & Gas, Singapore"
}, {
  "attributes" : {
    "type" : "Account",
    "url" : "/services/data/v24.0/sobjects/Account/001d000000Ard7vAAB"
  },
  "Id" : "001d000000Ard7vAAB",
  "Name" : "Edge Communications"
}{
  "attributes" : {
    "type" : "Account",
    "url" : "/services/data/v24.0/sobjects/Account/001d000000Ard7uAAB"
  },
  "Id" : "001d000000Ard7uAAB",
  "Name" : "United Oil & Gas, Singapore"
}, {
  "attributes" : {
    "type" : "Account",
    "url" : "/services/data/v24.0/sobjects/Account/001d000000Ard7vAAB"
  },
  "Id" : "001d000000Ard7vAAB",
  "Name" : "Edge Communications"
}

Although this is a list of accounts, you can see that the json response is contained in curly brackets ({}) and NOT in square brackets ([]). Try changing your square brackets to curly ones.

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.