SOLVED

Re: Updating custom fields of Leads

Go to solution
Sardor_Taylakov
Level 1

Updating custom fields of Leads

I store leads and get get leads by, for example, email by making a GET request to /rest/v1/leads.json?filterType=email&filterValues=example@example.com endpoint. I get the following as a result:

{
    "requestId""212121",
    "result": [
        {
            "id": 121212,
            "firstName""First",
            "lastName""Last",
            "email""example@example.com",
            "updatedAt""2020-01-10T17:16:38Z",
            "createdAt""2020-01-10T17:11:11Z"
        }
    ],
    "success"true
}

From here I can get the id of a lead. So I want to update a custom field this lead has (let's call it allowedToEmail). I can also get details about it by making a GET request to /rest/v1/leads/describe.json endpoint:

{
            "id": 21,
            "displayName""Allowed to email",
            "dataType""boolean",
            "soap": {
                "name""allowedToEmail",
                "readOnly"false
            },
            "rest": {
                "name""allowedToEmail",
                "readOnly"false
            }
        }

What I want is to update its value to false, making a POST request to /rest/v1/leads.json with the following body does is not working:

{
    "action": "updateOnly",
    "input": [
        {
            "id": 4788743,

            "allowedToEmail": false
        }
    ]
}   

Any ideas on how this can be achieved? I greatly appreciate your help.

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Updating custom fields of Leads

You left out the 

lookupField

property.

Look more closely at the required payload.

View solution in original post

6 REPLIES 6
SanfordWhiteman
Level 10 - Community Moderator

Re: Updating custom fields of Leads

You left out the 

lookupField

property.

Look more closely at the required payload.

Sardor_Taylakov
Level 1

Re: Updating custom fields of Leads

Doing this does not help:

{
    "action": "updateOnly",
    "input": [
        {
            "id": 4788743,
            "membership": {
                "allowedToEmail": false
            }
        }
    ],
    "lookupField": "allowedToEmail"
}   

The error message is the following:

{
    "requestId""db2a#16f916cd626",
    "success"false,
    "errors": [
        {
            "code""1011",
            "message""Lookup field 'allowedToEmail' not supported"
        }
    ]
}
I am getting the impression that what I am trying to do is not possible via exposed APIs. Could you please confirm if I am right or whether this is under assets?
I appreciate your time and effort.
SanfordWhiteman
Level 10 - Community Moderator

Re: Updating custom fields of Leads

I am getting the impression that what I am trying to do is not possible via exposed APIs. 

Of course it’s possible to update lead fields!

Sardor_Taylakov
Level 1

Re: Updating custom fields of Leads

Sanford Whiteman‌ it works perfect now. You made my day!

SanfordWhiteman
Level 10 - Community Moderator

Re: Updating custom fields of Leads

Cool, pls mark my answer as Correct, thanks.

SanfordWhiteman
Level 10 - Community Moderator

Re: Updating custom fields of Leads

The lookup field is id.