{{sidenavigation.sidenavigationExpandLabel}}
{{getMsg('Help_YouAreHere')}}: {{page.title}} {{page.title}}
{{$root.getMsg("downLoadHelpAsPdf")}} {{helpModel.downloadHelpPdfDataStatus}}

Assets

The information from an asset includes fields set for the current asset type. You have to provide a valid asset id and must be eligible to read information from that asset. That is: you are either the owner of that asset or you have read access to all available assets

GET /api/inventory/<asset-id>

Request the detailed information about an asset with the given <asset-id>. The response is sent back using JSON.

RESPONSE Fields Value Type Description
id GUID The GUID of an asset
parent GUID The GUID of the parent asset or null if not set
name String The display name of the asset
isArchived Boolean True, if the asset is in the archived state.
type Object The asset type object
type.id Number The asset type index
type.name String The display name of the asset type
image String The image file name from the attachments that denotes the asset image
hasAttachments Boolean True, if there are any attachments associated with this asset
fields Map<String, Object> A key-value map of asset fields set for the current asset type

Asset Fields

Each asset type consists of a list of connected asset fields. The fields contain the actual information about an asset. The fields entry in the response contains the key of an asset field and the current value. If there is no value set for any given asset field, it will not be returned using the Web API. However, you may be able to update the field.

Note: as asset may actually have more fields set, e.g. when the type was changed at some point. In that case, only the fields of the current asset type are returned.

Note: asset can have owners, which is not required. That is why the owner field, a GUID, is part of the fields section. If the owner is not set, it will be omitted from the fields map.

Example Request

# Request
GET /api/inventory/0000000014dda45eb9fe2ecb0 HTTP/1.1
Authorization: Bearer VGhpcyBpcyBqdXN0IGEgZGVtbyBhY2Nlc3MgdG9rZW4u
 
# Response
HTTP/1.1 200 OK
Content-Type: application/json
 
{
  "id": "0000000014dda45eb9fe2ecb0",
  "parent": null,
  "name": "Dell Precision T3400",
  "isArchived": false,
  "type": {
    "id": 11,
    "name": "Computer"
  },
  "hasAttachments": false,
  "fields": {
    "owner": "sys02qmoxwlwprnnovhrxtx7n",
    "license": 0,
    "serialnumber": "G 1234 5678 90",
    "purchasedate": 1629410400000,
    "price": 1399.5,
    "vendor": 1,
    "name": "Dell Precision T3400",
    "warranty": 1692482400000,
    "sla": 2,
    "location": 0,
    "custom1": "10.1.1.10",
    "assetnumber": "X123"
  }
}

Application Example

# Browser access
http://127.0.0.1:9000/api/inventory/0000000014dda45eb9fe2ecb0
 
# Shell access using curl
curl -LsH "Authorization: Bearer <access_token>" "http://127.0.0.1:9000/api/inventory/0000000014dda45eb9fe2ecb0"
 
# Shell access using curl using username and password
curl -Lsu username:password "http://127.0.0.1:9000/api/inventory/0000000014dda45eb9fe2ecb0"

Updating Assets: POST /api/inventory/<asset-id>

To update an asset, send a POST request to the asset handler. The request contains a map of asset field keys and the updated values. Please look at the creation handler for additional details.

Note: you can update the parent field to change the asset's position in the tree.

Example Request

# Request
POST /api/inventory/7nu5btw9hxubqkc0baeca8fgp HTTP/1.1
Authorization: Bearer VGhpcyBpcyBqdXN0IGEgZGVtbyBhY2Nlc3MgdG9rZW4u
Content-Type: application/json
 
{
  "name": "Microsoft Office 182",
}
 
# Response
HTTP/1.1 200 OK
Content-Type: application/json
 
{
  "id": "7nu5btw9hxubqkc0baeca8fgp",
  "parent": "0xzpx5c1axxj8fa3t3r926kgd",
  "name": "Microsoft Office 182",
  "isArchived": false,
  "type": {
    "id": 26,
    "name": "Software"
  },
  "hasAttachments": false,
  "fields": {
    "owner": "26ljl61fdu8napr0sopu2ovqs",
    "license": 1,
    "purchasedate": 1700002800000,
    "price": 2037.3836663611166,
    "vendor": 1,
    "mycustomfield": "A custom value",
    "name": "Microsoft Office 365",
    "sla": 3,
    "location": 56,
    "assetnumber": "DE-42-11",
    "costcenter": "General",
    "room": "120"
  }
}

Application Example

# Browser access
http://127.0.0.1:9000/api/inventory/create
 
# Shell access using curl
curl -Ls "http://127.0.0.1:9000/api/inventory/7nu5btw9hxubqkc0baeca8fgp" \
     --header 'Authorization: Bearer VGhpcyBpcyBqdXN0IGEgZGVtbyBhY2Nlc3MgdG9rZW4u' \
     --header "Content-Type: application/json" \
     --request POST \
     --data '{"name": "Microsoft Office 182"}'
 
# Shell access using curl with username and password
curl -Lsu username:password "http://127.0.0.1:9000/api/inventory/7nu5btw9hxubqkc0baeca8fgp" \
     --header "Content-Type: application/json" \
     --request POST \
     --data '{"name": "Microsoft Office 182"}'

Adding Attachments

The request allows the upload of additional attachments. The following requirements have to be fulfilled for an attachment upload:

  • The request has to be performed using the Content-Type: multipart/form-data header
  • The JSON itself has to be sent as file attachment using the attribute name json
  • Attachment files have to have the attribute name attachment<X> with <X> being a number starting at 0; corresponding to the index of the attachment description list for the given attachment.
  • The JSON may contain a list of attachment descriptions (see below). The entry index has to match your attachment<X> - file. The list of attachment descriptions can be added to your JSON map using the attachments key.
REQUEST Fields Value Type Description
name string The file name of the attachment
lastModified long The timestamp of the last modification of this attachment (can be 0)

Note: The attachments field in the JSON is optional. However, if set, you can send the name and the lastModified date along. If the attachments field is omitted, the file name is derived from the file's multipart header.

Application Example

# Browser access
http://127.0.0.1:9000/api/inventory/create
http://127.0.0.1:9000/api/inventory/<asset-id>
 
# Shell access using curl
curl -Ls "http://127.0.0.1:9000/api/inventory/<asset-id>" \
     --header 'Authorization: Bearer VGhpcyBpcyBqdXN0IGEgZGVtbyBhY2Nlc3MgdG9rZW4u' \
     --header "Content-Type: multipart/form-data" \
     --request POST \
     --form 'json={}'
     --form attachment0="@first attachment.pdf"
     --form attachment1="@second attachment.pdf"
 
# Shell access using curl with username and password
curl -Lsu username:password "http://127.0.0.1:9000/api/inventory/<asset-id>" \
     --header "Content-Type: multipart/form-data" \
     --request POST \
     --form 'json={}'
     --form attachment0="@first attachment.pdf"
     --form attachment1="@second attachment.pdf"
 
# Note: The ''@'' sign is required for curl to recognize the input as a file.

Note: The example is valid for updating an asset. You can also send attachments along with an asset creation request. In that case, the JSON has to have at least the fields type and name.

To send a different attachment name and the lastModified field, please add the attachments field using the following JSON snippet.

{
  "attachments": [
    {
      "name": "first attachment.pdf",
      "lastModified": 0
    },
    {
      "name": "second attachment.pdf",
      "lastModified": 0
    }
  ]
}
i-net HelpDesk
This application uses cookies to allow login. By continuing to use this application, you agree to the use of cookies.


Help - /<asset-id>