function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Francois LefebvreFrancois Lefebvre 

Bulk API Load data in Master-Detail field

Hello,
We are using the Bulk API to insert records in a custom object, which uses a Master-Detail field to the Contact object. 
I am sending my data in JSON format.  Here is a sample of that payload:  (Contact__r is the Relationship Name of the Master-Detail field)
[
    {
        "Subscriber_Key__c": "0030a00001sjeAXAAY",
        "Contact__r": {
            "Id": "0030a00001sjeAXAAY"
        },
        "Job_Id__c": "72299",
        "Subscriber_ID__c": "35827818",
        "Email_Address__c": "shelby@email.com",
        "Email_Name__c": "Early Bird Template Based Email - 20181211_132833",
        "Email_Subject__c": "test email",
        "Dynamic_Email_Subject__c": "",
        "From_Name__c": "Pittsburgh Three Rivers Marathon, Inc. (P3R)",
        "From_Email__c": "Long@email.com",
        "Event_Type__c": "Send",
        "Event_Sub_Type__c": "",
        "Event_Date__c": "2019-01-08",
        "Is_Unique__c": false,
        "URL__c": "",
        "Account__c": "100012345",
        "Business_Unit_Id__c": "100012345"
    },
    {
        "Subscriber_Key__c": "0030a000024Mv81AAC",
        "Contact__r": {
            "Id": "0030a000024Mv81AAC"
        },
        "Job_Id__c": "72299",
        "Subscriber_ID__c": "35827820",
        "Email_Address__c": "brady@email.com",
        "Email_Name__c": "Early Bird Template Based Email - 20181211_132833",
        "Email_Subject__c": "test email",
        "Dynamic_Email_Subject__c": "",
        "From_Name__c": "Pittsburgh Three Rivers Marathon, Inc. (P3R)",
        "From_Email__c": "Long@email.com",
        "Event_Type__c": "Send",
        "Event_Sub_Type__c": "",
        "Event_Date__c": "2019-01-08",
        "Is_Unique__c": false,
        "URL__c": "",
        "Account__c": "100012345",
        "Business_Unit_Id__c": "100012345"
    },
    {
        "Subscriber_Key__c": "0031800000UnAxwAAF",
        "Contact__r": {
            "Id": "0031800000UnAxwAAF"
        },
        "Job_Id__c": "57113",
        "Subscriber_ID__c": "34693791",
        "Email_Address__c": "lennie@email.com",
        "Email_Name__c": "Abandoned Page",
        "Email_Subject__c": "%%First Name%%, you can still get discounted registration and free swag",
        "Dynamic_Email_Subject__c": "",
        "From_Name__c": "Pittsburgh Three Rivers Marathon, Inc. (P3R)",
        "From_Email__c": "Long@email.com",
        "Event_Type__c": "Click",
        "Event_Sub_Type__c": "",
        "Event_Date__c": "2019-01-07",
        "Is_Unique__c": true,
        "URL__c": "",
        "Account__c": "100012345",
        "Business_Unit_Id__c": "100012345"
    },
    {
        "Subscriber_Key__c": "0031800000UnAxwAAF",
        "Contact__r": {
            "Id": "0031800000UnAxwAAF"
        },
        "Job_Id__c": "57113",
        "Subscriber_ID__c": "34693791",
        "Email_Address__c": "lennie@email.com",
        "Email_Name__c": "Abandoned Page",
        "Email_Subject__c": "%%First Name%%, you can still get discounted registration and free swag",
        "Dynamic_Email_Subject__c": "",
        "From_Name__c": "Pittsburgh Three Rivers Marathon, Inc. (P3R)",
        "From_Email__c": "Long@email.com",
        "Event_Type__c": "Open",
        "Event_Sub_Type__c": "",
        "Event_Date__c": "2019-01-07",
        "Is_Unique__c": false,
        "URL__c": "",
        "Account__c": "100012345",
        "Business_Unit_Id__c": "100012345"
    },
    {
        "Subscriber_Key__c": "0030a000024Mv81AAC",
        "Contact__r": {
            "Id": "0030a000024Mv81AAC"
        },
        "Job_Id__c": "72299",
        "Subscriber_ID__c": "35827820",
        "Email_Address__c": "brady@email.com",
        "Email_Name__c": "Early Bird Template Based Email - 20181211_132833",
        "Email_Subject__c": "test email",
        "Dynamic_Email_Subject__c": "",
        "From_Name__c": "Pittsburgh Three Rivers Marathon, Inc. (P3R)",
        "From_Email__c": "Long@email.com",
        "Event_Type__c": "Open",
        "Event_Sub_Type__c": "",
        "Event_Date__c": "2019-01-08",
        "Is_Unique__c": true,
        "URL__c": "",
        "Account__c": "100012345",
        "Business_Unit_Id__c": "100012345"
    },
    {
        "Subscriber_Key__c": "0030a00001sjeAXAAY",
        "Contact__r": {
            "Id": "0030a00001sjeAXAAY"
        },
        "Job_Id__c": "72299",
        "Subscriber_ID__c": "35827818",
        "Email_Address__c": "shelby@email.com",
        "Email_Name__c": "Early Bird Template Based Email - 20181211_132833",
        "Email_Subject__c": "test email",
        "Dynamic_Email_Subject__c": "",
        "From_Name__c": "Pittsburgh Three Rivers Marathon, Inc. (P3R)",
        "From_Email__c": "Long@email.com",
        "Event_Type__c": "Open",
        "Event_Sub_Type__c": "",
        "Event_Date__c": "2019-01-08",
        "Is_Unique__c": true,
        "URL__c": "",
        "Account__c": "100012345",
        "Business_Unit_Id__c": "100012345"
    },
    {
        "Subscriber_Key__c": "0030a000024Mv81AAC",
        "Contact__r": {
            "Id": "0030a000024Mv81AAC"
        },
        "Job_Id__c": "72299",
        "Subscriber_ID__c": "35827820",
        "Email_Address__c": "brady@email.com",
        "Email_Name__c": "Early Bird Template Based Email - 20181211_132833",
        "Email_Subject__c": "test email",
        "Dynamic_Email_Subject__c": "",
        "From_Name__c": "Pittsburgh Three Rivers Marathon, Inc. (P3R)",
        "From_Email__c": "Long@email.com",
        "Event_Type__c": "Open",
        "Event_Sub_Type__c": "",
        "Event_Date__c": "2019-01-08",
        "Is_Unique__c": false,
        "URL__c": "",
        "Account__c": "100012345",
        "Business_Unit_Id__c": "100012345"
    }
]
However, the result of the Bulk API is always that the Id field of Contact is not an External ID or not indexed. 
[
    {
        "success": false,
        "created": false,
        "id": null,
        "errors": [
            {
                "message": "Field name provided, Id is not an External ID or indexed field for Contact",
                "fields": [],
                "statusCode": "INVALID_FIELD",
                "extendedErrorDetails": null
            }
        ]
    },
    {
        "success": false,
        "created": false,
        "id": null,
        "errors": [
            {
                "message": "Field name provided, Id is not an External ID or indexed field for Contact",
                "fields": [],
                "statusCode": "INVALID_FIELD",
                "extendedErrorDetails": null
            }
        ]
    },
    {
        "success": false,
        "created": false,
        "id": null,
        "errors": [
            {
                "message": "Field name provided, Id is not an External ID or indexed field for Contact",
                "fields": [],
                "statusCode": "INVALID_FIELD",
                "extendedErrorDetails": null
            }
        ]
    },
    {
        "success": false,
        "created": false,
        "id": null,
        "errors": [
            {
                "message": "Field name provided, Id is not an External ID or indexed field for Contact",
                "fields": [],
                "statusCode": "INVALID_FIELD",
                "extendedErrorDetails": null
            }
        ]
    },
    {
        "success": false,
        "created": false,
        "id": null,
        "errors": [
            {
                "message": "Field name provided, Id is not an External ID or indexed field for Contact",
                "fields": [],
                "statusCode": "INVALID_FIELD",
                "extendedErrorDetails": null
            }
        ]
    },
    {
        "success": false,
        "created": false,
        "id": null,
        "errors": [
            {
                "message": "Field name provided, Id is not an External ID or indexed field for Contact",
                "fields": [],
                "statusCode": "INVALID_FIELD",
                "extendedErrorDetails": null
            }
        ]
    },
    {
        "success": false,
        "created": false,
        "id": null,
        "errors": [
            {
                "message": "Field name provided, Id is not an External ID or indexed field for Contact",
                "fields": [],
                "statusCode": "INVALID_FIELD",
                "extendedErrorDetails": null
            }
        ]
    }
]
I was under the impression that the ID field of standard object is always indexed by default.  Is there anything else that need to be done to either the custom object or Contact to allow the lookup ?

Any advice or insight would be much appreciated.

Thank you!
Cheers,

Francois
Roberto MartucciRoberto Martucci

Same problem here.

Any help?

Somya TiwariSomya Tiwari
Insted of using Contact__r you must specify Contact ID which must be on your custom Object.