SOLVED

Add 1:N relationship Custom Object via REST API

Go to solution
Highlighted
Anonymous
Not applicable

Add 1:N relationship Custom Object via REST API

Hi all

I'm trying to add 1:N relationship custom objects to the lead via REST API Create/Update/Upsert Custom Objects » Marketo Developers .

But API response is {"code":"1017","message":"Record already exists"}.

How can I add 1:N objects to a lead?

Request

https://999-XXX-999.mktorest.com/rest/v1/customobjects/rireki.json?access_token=xxxxxxxxxxxxxxxxxxxx...

{

   "action":"createOnly",

   "input":[

      {

         "id":1011725,

         "datetime":"2015-11-16T12:34:56+09:00",

         "count":3,

      }

   ]

}

Response

{"requestId":"12579#1511345606b","result":[

{"seq":0,"status":"skipped","reasons":[

{"code":"1017","message":"Record already exists"}

]}

],"success":true}

Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Add 1:N relationship Custom Object via REST API

Hi Takehiro Masaki,

When setting up custom object, you need to specify what field links to the lead (Data type = Link), then you will specify to which lead or company field it is linked). Typically, you will link to the Lead.id or Lead.email address fields. I gather in this case it's the ID field.

Furthermore, you may specify what field is a Unique ID for the custom object. Set any field Type as you want, and then use the "Dedupe field" toggle to set this field as a unique ID. This allows Marketo to distinguish between the records you are inserting. In your case, do you have a deduplicate field?

And then, when you create the custom object through the API, these 2 fields will have to be provided.

Here, in your import, I do not see what is the link field and the Unique ID field. Please provide a screenshot of the Field definition for your custom object so that can help you further.

-Greg

View solution in original post

4 REPLIES 4
Highlighted

Re: Add 1:N relationship Custom Object via REST API

Hi Takehiro Masaki,

When setting up custom object, you need to specify what field links to the lead (Data type = Link), then you will specify to which lead or company field it is linked). Typically, you will link to the Lead.id or Lead.email address fields. I gather in this case it's the ID field.

Furthermore, you may specify what field is a Unique ID for the custom object. Set any field Type as you want, and then use the "Dedupe field" toggle to set this field as a unique ID. This allows Marketo to distinguish between the records you are inserting. In your case, do you have a deduplicate field?

And then, when you create the custom object through the API, these 2 fields will have to be provided.

Here, in your import, I do not see what is the link field and the Unique ID field. Please provide a screenshot of the Field definition for your custom object so that can help you further.

-Greg

View solution in original post

Highlighted
Anonymous
Not applicable

Re: Add 1:N relationship Custom Object via REST API

Thank you Grégoire Michel​ and Kenny

i misunderstood link field and dedupe field.

I had set 'id' field to dedupe field.

When I changed my 'datetime' field to dedupe, I could create 1:N relationship.

Highlighted

Re: Add 1:N relationship Custom Object via REST API

Hi again Takehiro Masaki​,

PLs close the question, then.

-Greg

Highlighted
Marketo Employee

Re: Add 1:N relationship Custom Object via REST API

Two things here.  createOnly will not create a record if there is already a record matching your key, you need to have a net new unique identifier  for createOnly mode.  Second it's not clear what key type that you're trying to specify here, so your call may be ambiguous.