Kaseya Community

API help - get custom fields returns (403) forbidden error

  • I have been able to use the API to get the default values for Agents but not the custom fields.

    This syntax works to get the default fields:

    $uri = "https://my.vsa.company.com/api/v1.0/assetmgmt/agents?"
    $result = invoke-restmethod -uri $uri -Headers @{'Authorization'="Bearer $token"} -Method Get -ContentType application/json
    $result.result

    If I grab an individual AgentId from the above results and use it, for example (AgentId : 123463795423374) I get a '(403) Forbidden' error when I try to access the custom fields with this syntax:

    $uri = "https://my.vsa.company.com/api/v1.0/assets/123463795423374/customfields"
    $result = invoke-restmethod -uri $uri -Headers @{'Authorization'="Bearer $token"} -Method Get -ContentType application/json
    $result.result

    I have been following the instructions in the guide http://help.kaseya.com/webhelp/EN/RESTAPI/9050000/#37928.htm where it states to use:  /assetmgmt/assets/{agentId}/customfields

    Is this a bug or is my syntax wrong?

    Thanks in advance for any help!

  • My working URI is  /assetmgmt/assets/#######/customfields.. your URI above is missing "/assetmgmt", even though you say the docs include the /assetmgmt part.

    I've got a tool that manages the CF data - backing it up, restoring, or even migrating it to another VSA when upgrading platforms. If you mis-reference the path, you'll get a 403 for sure.

    Glenn

  • Thank you for the second set of eyes !

    Coding at 5PM on Friday got me :-|

    Appreciate your help, it works like a charm now.

  • So 4 eyes and 6 brain cells are the minimum requirement! Glad it worked!

    Glenn