KACE API to update an asset
Ok so I'll start with a rant -- hey KACE, why even put the development effort or dollars on something you're not going to properly document for your users? Basically, you've spent the cycles creating something most of us are going to fail at fully implementing. I'm not sure the business rationale behind that.
I just talked to KACE and the only official response they can give me is to refer to the documentation. Hey, it's OK if you RTFM me, but only if your FM is complete and usable.
Ok, so my question --
I can query assets fine from the API, but the documentation says that the "body" data for a PUT to api/asset/assets/{id} is "string array".
My guess is that this is a JSON string representing a JSON array? Am I far off?
Either way, does someone have a valid example of that JSON should like?
All I get back form the KACE server is a 500 error, so I'm guessing I have invalid input.
I'm doing the PUT from PS using the following line --
Invoke-WebRequest $base_uri/asset/assets/$asset_id -Method Put -Headers $headers -WebSession $my_session -Body $body
So, how is the $body string supposed to be structured?
Anyone tackle this?
The lack of examples in the documentation is FRUSTRATING!
I don't need hand holding, but GOD GIVE US AT LEAST ONE EXAMPLE PLEASE!
2 Comments
[ + ] Show comments
Answers (2)
Answer Summary:
Please log in to answer
Posted by:
AbhayR
6 years ago
Top Answer
To update an asset, you need to use the body format as below
{
"Assets": [
{
"name": "AssetName"
}
]
}
Comments:
-
Awesome, exactly what I was looking for. - ndelo 6 years ago
-
Sweet - AbhayR 6 years ago
-
I think part of my problem is that I am now noticing that my test assets are/were updating, but the K1000 is still (in certain conditions) returning a 500 error at the API.
I think my assumption was that I had invalid JSON for the body, but now I'm suspecting it's perhaps something else entirely.
The same test clients that throw a 500 from the API are also throwing an "Oops" error in the web GUI console when I edit the asset record and save it.
Anyway, thanks again for the example, as it's gotten me a bit further along.
I'll have to troubleshoot this more. - ndelo 6 years ago
-
https://www.itninja.com/blog/view/i-wrote-an-open-source-powershell-module-for-the-kace-sma-api
In addition to this, in writing my powershell module above, i encountered this (including the maddening WTF is assetData schema).
I found if you include the following data in your json payload, it creates the asset successfully.
@{
'name'='x2test'
"asset_type_id" = 5
'location_id' = 12345
'asset_type_name' = "Computer with Dell Agent"
} - isudothings 6 years ago
Posted by:
AbhayR
6 years ago
What are the headers you are using ?
Comments:
-
$headers = @{
"Accept" = "application/json";
"Content-Type" = "application/json";
"x-dell-api-version" = "8";
"x-dell-csrf-token" = $csrf_token
}
Like I said, the problematic assets also throw an error when I update them from the GUI as well.
I need to check if this is simply a problem with a small number of test nodes on my test system. It may be an artifact of other tests/upgrades we've done in the past and my not affect our eventual prod upgrade/system.
The JSON you posted me last week did the trick however and what what I was looking for. - ndelo 6 years ago
https://support.quest.com/technical-documents/kace-sma/8.0/api-reference-guide/
It seems there are some examples too:
https://support.quest.com/technical-documents/kace-sma/8.0/api-reference-guide/5#TOPIC-850775
There is also a disclaimer at top
" Our Support team does not provide assistance for any custom development that implements the APIs covered in this guide which is in line with our support policy. "
There are some ITninja users that might be able to help you wiht API coding. - Channeler 6 years ago
The few examples they have are for access/authentication and how to filter queries to the API. They've done an OK job documenting that portion.
However, the full API reference in the document lacks any real examples of how to use the other calls available. For instance, like i said, the asset update call says it expects 'assetData', and that its schema is a string/array. But that's kind of vague.
I've even queried an asset, taken its JSON output (which also falls under the string schema) and used that as the input, and the SMA API rejects it for some reason.
This leads me to wonder what exactly is the structure of the input it's expecting? One is left to guess. I'm guessing a JSON string containing a structured array of data, but that's not enough for one to go on. - ndelo 6 years ago
---------
PUT /api/asset/assets/{id}
Description:
Updates an asset.
Parameters:
Type Name Schema
Path id required integer
Body assetData required string array - ndelo 6 years ago