Error when attempting a POST via Postman to add an asset

When attempting to add an asset via a POST request using Postman I receive the following error-

{
    "description": "Validation failed",
    "errors": [
        {
            "field": "asset_type_id",
            "message": "It should not be blank as this is a mandatory field",
            "code": "invalid_value"
        }
    ]
}

I know the asset_type_id is required and I am sending it in the body of my POST request, yet I still receive that error. Below is the body of my POST request using fake asset data-

{
    "assets": [
        {
            "name": "Test Asset 2",
            "asset_type_id": 21001763948,
            "asset_tag": "123456789",
            "impact": "high",
            "description": "Windows Server 2019 Bear Metal",
            "end_of_life": null,
            "discovery_enabled": true,
            "usage_type": "permanent",
            "created_by_source": "User",
            "created_by_user": 21001731560,
            "created_at": "2024-08-28T17:28:24Z",
            "last_updated_by_source": "User",
            "last_updated_by_user": 21001731560,
            "updated_at": "2024-10-04T23:49:58Z",
            "sources": [
                "User"
            ],
            "location_id": 21000528268,
            "department_id": 21000246486,
            "agent_id": null,
            "user_id": null,
            "group_id": 21000361728,
            "assigned_on": null,
            "author_type": "User",
            "id": 21003971077,
            "display_id": 9
        }
    ]
}

Can someone help with this? It seems to me that the asset_type_id is being generated by Freshservice because that’s not something that I entered when I manually added the fake asset. But when I performed a GET request, the asset_type_id was returned in the response. So I took that same data and tried to use it when I performed the POST in order to add the asset, yet I still received the error referenced above.

Hello @mdragoo, a couple things, did you verify the asset_type_id matches what it shows in the URL when you are in the “edit” screen of that asset type? That is the asset _type_id number you will want to pass in your POST request.


Secondly in the JSON payload that you sent as your example, you are trying to send “id”, this cannot be sent to the “Create Asset” endpoint, as its an assigned value once the asset is created.

Hope that helps.

1 Like

Thank you for the reply, Zach! I will try this out.