Asset update API validation error for Managed By field

Hi,

I am trying to update an asset using the REST API:
PUT https://[instance]/api/v2/assets/8577/

The JSON payload being sent is:

{
    "impact": "low",
    "user_id": 16000418100,
    "description": "Business App 5 Description b",
    "type_fields": {},
    "group_id": 16000308791,
    "asset_type_id": 16000480446,
    "name": "Business App 5"
}

The asset I am trying to update is asset type Business Service and has the following values:

The group_id of 16000308791 which is being sent in the payload is the id of Engineering, so I am updating the asset with the same Managed By Group that it is already set to.

The user_id of 16000418100 which is being sent in the payload is the id of Chris Scaglione, so I am updating the asset with the same Used By that it is already set to.

I am not passing an agent_id. I expect it to keep the same value that is already set in the Managed By field. However, I am getting the following validation error response:

{
    "description": "Validation failed",
    "errors": [
        {
            "field": "agent_id",
            "message": "Assigned agent isn't a member of the group.",
            "code": "invalid_value"
        }
    ]
}

Is there an issue with the JSON payload that I am sending or with the asset update API?

Thanks

Hi @Chris_Scaglione ,

Can you please tell asset_type_id: 16000480446 refers to what type as Name?
Also did this 16000418100 (Chris Scaglione) are part of that specified group?

Hi @Umar,

16000480446 is the Business Service asset type. From the https://[instance]/api/v2/asset_types API call:

{
    "asset_types": [
        {
            "id": 16000480426,
            "name": "Services",
            "parent_asset_type_id": null,
            "visible": true,
            "description": "",
            "created_at": "2020-05-06T23:53:37Z",
            "updated_at": "2020-05-06T23:53:37Z"
        },
        {
            "id": 16000480446,
            "name": "Business Service",
            "parent_asset_type_id": 16000480426,
            "visible": true,
            "description": "",
            "created_at": "2020-05-06T23:53:37Z",
            "updated_at": "2020-05-06T23:53:37Z"
        },
        ...
}

Yes, 16000418100 (Chris Scaglione) is a member of the Engineering group.

If I send a PUT https://[instance]/api/v2/assets/8577/ with the following payload where the agent_id is specified:

{
    "impact": "low",
    "user_id": 16000418100,
    "agent_id": 16000418100,
    "description": "Business App 5 Description b",
    "type_fields": {},
    "group_id": 16000308791,
    "asset_type_id": 16000480446,
    "name": "Business App 5"
}

It saves without any error:

{
    "asset": {
        "id": 16002024853,
        "display_id": 8577,
        "name": "Business App 5",
        "description": "Business App 5 Description b",
        "asset_type_id": 16000480446,
        "impact": "low",
        "author_type": "User",
        "usage_type": "permanent",
        "asset_tag": "ASSET-8577",
        "user_id": 16000418100,
        "department_id": null,
        "location_id": null,
        "agent_id": 16000418100,
        "group_id": 16000308791,
        "assigned_on": null,
        "created_at": "2023-01-19T01:28:02Z",
        "updated_at": "2023-01-20T01:14:37Z",
        "end_of_life": null,
        "attachments": [],
        "cloud_files": [],
        "type_fields": {
            "sla_16000480446": null,
            "cost_16000480446": null
        }
    }
}

The issue is if I don’t sent agent_id in the payload and the Managed By field is already filled in with a valid user for the Managed By Group that is sent in the payload, then I get the error:

{
    "description": "Validation failed",
    "errors": [
        {
            "field": "agent_id",
            "message": "Assigned agent isn't a member of the group.",
            "code": "invalid_value"
        }
    ]
}

Thanks

Hey @Chris_Scaglione, there is no issue with your payload and this is unfortunately the API behavior.

After looking around for a fix, the product team has confirmed it to be a bug and it is on the roadmap for an update and release soon.

Thank you so much bringing it to our notice. For now please include the agent_id in the payload. I will keep you posted here when it is GA.

Cheers!

Hi @Debjani,

Thank you for looking into this and confirming! We will do what you suggested and send the agent_id with the payload.

Thanks

Chris

1 Like