/bundles/itninjaweb/img/Breadcrumb_cap_w.png
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 -- 

Can anyone give me a clue on how to structure the assetData string/array to update information on an asset?

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!


Answer Summary:
Cancel
2 Comments   [ - ] Hide Comments

Comments

  • I haven't use the API portion but here is a reference document in regards that:

    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.
  • Yeah, I've fully read the documentation.
    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.
    • Here's the complete documentation for updating an asset. Again, if someone can give me an example of what the 'assetData' string in the body is supposed to look like, I'd be eternally grateful

      ---------

      PUT /api/asset/assets/{id}

      Description:
      Updates an asset.

      Parameters:
      Type Name Schema
      Path id required integer
      Body assetData required string array
Please log in to comment

Answer Chosen by the Author


Answers

1
To update an asset, you need to use the body format as below

{
  "Assets": [
    {
      "name": "AssetName"
    
    }
  ]
}
Answered 01/03/2018 by: AbhayR
Seventh Degree Black Belt

  • Awesome, exactly what I was looking for.
    • Sweet
      • 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.
Please log in to comment
Answer this question or Comment on this question for clarity

Answers

0
What are the headers you are using ?
Answered 01/03/2018 by: AbhayR
Seventh Degree Black Belt

  • $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.
Please log in to comment
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja

Share