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": "[email protected]",
        "ContactAttributes": {
            "SubscriberAttributes": {
                "Brand_Code": "BM",
                "Country_Code": "GB",
                "EmailAddress": "[email protected]",
                "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": "[email protected]"
    }
},
{
"From": {},
"To":
    {
        "Address": "[email protected]",
        "ContactAttributes": {
            "SubscriberAttributes": {
                "Brand_Code": "BM",
                "Country_Code": "GB",
                "EmailAddress": "[email protected]",
                "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": "[email protected]"
    }
}
]

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 ?

3
  • There is a related issue here: salesforce.stackexchange.com/questions/46095/…. Could it be that you are manually generating the json file and thus is not a valid json? Adding some code would help. Commented Apr 5, 2019 at 13:11
  • Yes, for tests, i have manually generated this json. I used a json validator to be sure it is correct
    – Konynrith
    Commented Apr 5, 2019 at 13:19
  • Just try without [] Commented Apr 5, 2019 at 13:33

2 Answers 2

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.

4
  • This is not a solution in case you want to return a list of json objects at once. Commented Apr 5, 2019 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
    Commented Apr 5, 2019 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. Commented Apr 5, 2019 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
    Commented Apr 5, 2019 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .