SOLVED

Re: Update leads via API using ID?

Go to solution
Andy_Varshneya1
Level 9

Update leads via API using ID?

Looking at http://developers.marketo.com/documentation/rest/createupdate-leads/  it says we can set the lookupField in order to have some control over how to identify the leads we are updating. However, when you export all fields, you see that the ID is not available to the REST API.

We tried to get around this by creating a formula field that copies the value of the MarketoID over, but that is also not allowed as the MarketoID is only available as part of the IF statement and not THEN.

We also tried using the token {{lead.MarketoID}} to set the value in the formula field, but that also didn't work.

Has anyone else run into this problem before, and if so, how have you addressed it?

Tags (3)
1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Re: Update leads via API using ID?

Hi Myokhaylo

According to http://developers.marketo.com/documentation/rest/createupdate-leads/

I think you need lookUpField parameter.

If lookUpField is not specified, email will be used for deduplication.

View solution in original post

9 REPLIES 9
SanfordWhiteman
Level 10 - Community Moderator

Re: Update leads via API using ID?

? The REST lookup field for Lead ID is just "id".

Andy_Varshneya1
Level 9

Re: Update leads via API using ID?

The error I'm getting is

{"requestId":"bd3e#15559d49a99","result":[{"status":"skipped","reasons":[{"code":"1003","message":"Field 'id' not allowed"}]}],"success":true}

SanfordWhiteman
Level 10 - Community Moderator

Re: Update leads via API using ID?

What's the full URL and body of the request?

Anonymous
Not applicable

Re: Update leads via API using ID?

URL: https://642-NLJ-561.mktorest.com/rest/v1/leads.json?access_token=xxx

1).

Request:

{"action": "updateOnly", "input": [{"id": 1000240, "leadScore": 6}]}

Respond:

{"requestId":"bd3e#15559d49a99","result":[{"status":"skipped","reasons":[{"code":"1003","message":"Field 'id' not allowed"}]}],"success":true}

2).

Request:

{"action": "updateOnly", "input": [{"email": "xxx@yyy.com", "leadScore": 6}]}

Respond:

{"requestId":"20b0#15559f4bae0","result":[{"id":1000240,"status":"updated"}],"success":true}

According to https://642-nlj-561.mktorest.com/rest/v1/leads/describe.json?access_token=xxx there is field „Id“ in the block „rest"

https://642-nlj-561.mktorest.com/rest/v1/leads/describe.json​{"id":42,"displayName":"Id","dataType":"integer","rest":{"name":"id","readOnly":false},"soap":{"name":"Id","readOnly":false}}

which looks similar analog to leadScore

{"id":143,"displayName":"Lead Score","dataType":"integer","rest":{"name":"leadScore","readOnly":false},"soap":{"name":"LeadScore","readOnly":false}}

what is the problem? what we are doing wrong? is it a bug or feature? it takes so much time to figure out. the examples on the developer page have no update examples for Rest API based on the lead id at all.

Another thing: when i go to Admin > Field Management > Export Field Names then i get Fields.xls downloaded and there is no "id" in the "REST API Name" column, which does not correspond to the lead's fields list under https://642-nlj-561.mktorest.com/rest/v1/leads/describe.json?access_token=xxx

Please Help?!

Andy_Varshneya1
Level 9

Re: Update leads via API using ID?

Well there's the problem. We weren't using lookupField="id" in the request.

It is working now.

Anonymous
Not applicable

Re: Update leads via API using ID?

Hi Myokhaylo

According to http://developers.marketo.com/documentation/rest/createupdate-leads/

I think you need lookUpField parameter.

If lookUpField is not specified, email will be used for deduplication.
Anonymous
Not applicable

Re: Update leads via API using ID?

You are right, now it works:

Request:

{"action": "updateOnly", "lookupField": "id", "input": [{"id": 1000240, "leadScore": 8}, {"id": 238, "leadScore": 1}]}

Response:

{"requestId":"1ee#1555eb7af81","result":[{"id":1000240,"status":"updated"},{"id":238,"status":"updated"}],"success":true}

Thanks to all!

Nicholas_Manojl
Level 9

Re: Update leads via API using ID?

Change the action to create or update, not create only. I can't articulate why this is.

SanfordWhiteman
Level 10 - Community Moderator

Re: Update leads via API using ID?

Because the ID is system-assigned?  Like if you did a MSSQL insert without IDENTITY_INSERT.