I want to update custom fields in kommo crm with make step "Kommo - Make an API Call"

I need to update custom fields in kommo crm. I tried to PATCH method in Make an API Call, with body:

[
{
        "name": "List",
        "id": 2981521,
        "enums": [
            {
                "value": "category 1",
                "sort": 1
            },
            {
                "value": "new category 2",
                "sort": 2
            },
            {
                "value": "new subcategory 1",
                "sort": 3
            }
        ]
    }
]

but i still get error:

[400] Bad Request Request validation failed

what I do wrong?

Include screenshots of


image

Are you certain that the body should start and end with square brackets? That doesn’t look right.

Try removing it like this

{
    "name": "List",
    "id": 2981521,
    "enums": [
        {
            "value": "category 1",
            "sort": 1
        },
        {
            "value": "new category 2",
            "sort": 2
        },
        {
            "value": "new subcategory 1",
            "sort": 3
        }
    ]
}
3 Likes

Than, I getting this error, I dont know what to do
image

According to the Kommo API documentation for Updating custom fields,

This method allows to update singular or multiple custom fields of an entity.

To update a singular custom field, you can add the field ID into the method URL (/api/v4/leads/custom_fields/{id}).

When updating multiple custom fields, an array of field objects is passed. In the case with a singular custom field, the field model is passed.

The URL that you used contains an ID, so it is updating a singular custom field. This means the array square brackets is not to be used.

Scrolling down to Request parameters section, here are the required field you need to send in the request:

If you do not send any of these properties, or send a property it wasn’t expecting to receive (like id), then validation will fail, thus you will get a 400 error.

3 Likes

If you scroll down a little further past the table, you will also see the section “HTTP response codes”. Here, it says that for error 400, that “Invalid data given. Details are available in the request response”.

You might not be able to see what fields are causing the validation failure from the Bundle popup, so you might need to install the Make/Integromat Dev Tool to view the full error message from the module.

3 Likes

I do what you said and fixed reques. but still get an error


See what this says

image

3 Likes


That error message from Kommo isn’t helpful either.

One last thing I can think of, is you cannot have any spaces before the first bracket, and last bracket, otherwise the request is not valid JSON.

If this still does not solve the issue, you might need to contact Kommo support.

3 Likes

Hi @pplanejane

When you use PATCH, you do need the square brackets “” indicating that you’re sending an array. This is because Patch can be used to update more than one record at a time.

Also, the Kommo docs say that the id is required in the Body (which you are doing), but not in the URL, so please try it without. The docs suggest:
/api/v4/leads/custom_fields without an id.

But can I ask? What type of field are you updating? The data says “category” and “subcategory”. If it is a category-type field, then you’ll need to use “nested” not “enums”. Plus each object will need an id and subcategories a parent_id.
Like in their example:

[
    {
        "id": 1278898091,
        "name": "New Category field name",
        "nested": [
            {
                "id": 197,
                "parent_id": null,
                "value": "category 1",
                "sort": 0
            },
            {
                "parent_id": null,
                "value": "new category 2",
                "sort": 1
            },
            {
                "parent_id": 197,
                "value": "new subcategory 1",
                "sort": 1
            }
        ]
    }
]

Please let us know how it goes.

3 Likes

@Terry_Hopper, it is possible to update just a single field, I even quoted this section

3 Likes

Thanks @samliew. :smiley:

You are right, of course. :+1: But it keeps it simple if we use the examples from the help page (which do include square brackets).

I think the problem never was the brackets… did you see the point about categories being passed as nested rather than enums?

4 Likes

I already contact kommo support and they send me this Update custom field in CRM

Thank you, I would try it. I want to update custom field that is select, like when you in kommo, you see custom field named “Courses”, and when you click you can see the list of courses for expample “First course”, “Second course” and etc. As for me I want to add/update this list with my list from make.

Enums are for type select, nested are for type category.

Here is an update:
when I use this body

[
    {
        "type": "select",
        "name": "Testing courses name",
        "enums": [
            {
                "value": "Abc",
                "sort": 1
            },
            {
                "value": "Bcd",
                "sort": 2
            },
            {
                "value": "Cde",
                "sort": 3
            }
        ]
    }
]

with this method URL

/v4/leads/custom_fields

I got a succesfull response, but it creates new custom field, not update

when I try to use code in body, like this

[
    {
        "type": "select",
        "name": "Testing courses name",
        "code": "2981521",
        "enums": [
            {
                "value": "Abc",
                "sort": 1
            },
            {
                "value": "Bcd",
                "sort": 2
            },
            {
                "value": "Cde",
                "sort": 3
            }
        ]
    }
]

I got an error

{
    "validation-errors": [
        {
            "request_id": "0",
            "errors": [
                {
                    "code": "NotSupportedChoice",
                    "path": "code",
                    "detail": "The value you selected is not a valid choice."
                }
            ]
        }
    ],
    "title": "Bad Request",
    "type": "https://httpstatus.es/400",
    "status": 400,
    "detail": "Request validation failed"
}

but with an ID in URL like this

/v4/leads/custom_fields/2981521

I get an error

{
    "validation-errors": [
        {
            "request_id": "0",
            "errors": [
                {
                    "code": "FieldNotExpected",
                    "path": "0",
                    "detail": "This field was not expected."
                }
            ]
        }
    ],
    "title": "Bad Request",
    "type": "https://httpstatus.es/400",
    "status": 400,
    "detail": "Request validation failed"
}

I dont know what to do, because I need to update custom field, not to create new.

UPDATE

SUCCESFULL!!!

I try to remove code field in body and put id (in docs there is not any mentions about field id)
like this

[
    {
        "type": "select",
        "name": "Testing courses name",
        "id": "2981521",
        "enums": [
            {
                "value": "Abc",
                "sort": 1
            },
            {
                "value": "Bcd",
                "sort": 2
            },
            {
                "value": "Cde",
                "sort": 3
            }
        ]
    }
]

with url like this

/v4/leads/custom_fields

and it WORKS! It update the custom field I want in kommo.
Thank you guys for helping me, without you, I could not have done it

4 Likes

Hey there @pplanejane :wave:,

Just thought I might step in and pat you on the back for the great job you did while figuring out this problem with @samliew’s and @Terry_Hopper’s help . I’m thrilled to see you were able to learn more about the product and come up with a solution! :clap:
Also thank you for stepping back into the community and sharing your solution with us. We greatly appreciate that.
Keep up the amazing work!

1 Like