SDP API 获取所有的资产

SDP API 获取所有的资产

SDP API 获取所有的资产

API调用URL地址

http://<serverName>:<portNumber>/api/v3/assets

示例:http://192.168.1.8:8080/api/v3/assets

请求参数

方法:GET

请求参数:

参数名

位置

input_data

<JSON_String>

params

authtoken

<API Key>

header

 

输入示例

{
    "list_info": {
        "row_count": "25",
        "get_total_count": true,
        "start_index": 1,
        "search_criteria": [
            {
                "field": "name",
                "value": "test",
                "condition": "contains",
                "logical_operator": "AND"
            }
,
            {
                "field": "product_type.name",
                "value": "test",
                "condition": "contains",
                "logical_operator": "AND"
            }

        ]
,
        "sort_field": "computer_system.service_tag",
        "sort_order": "asc",
        "fields_required": [
            "product_type",
            "operating_system.os",
            "ip_addresses",
            "vendor",
            "name",
            "computer_system.model",
            "org_serial_number",
            "state",
            "purchase_cost",
            "department",
            "user",
            "computer_system.service_tag",
            "icon",
            "ci",
            "operating_system.os",
            "last_success_audit"
        ]

    }

}
List_info中的值为API请求的参数,关键字解释如下:
”row_count”:”20”,为查询返回20个数据;
start_index“:1,为从第一个开始查询;
get_total_count:true,为获得所有数据计数。对应API响应中的 "total_count": 0;
search_fields:{"subject":"New hire", "priority.name":"high"},简单搜索条件,以上示例为检索主题为New hire和优先级为"high"的请求信息
"search_criteria":高级搜索条件,参考链接:ManageEngine卓豪技术支持
"sort_field":"subject":以主题为排序列;
sort_order:”asc”,为升序排列;
"fields_required",API需要返回的字段。不是所有的字段都可返回,仅页面中的列选择器可以选择的字段;

响应示例

{
    "assets": [
//符合条件的资产信息会在此输出
    ]
,
    "response_status": [
        {
            "status_code": 2000,
            "status": "success"
        }

    ]
,
    "list_info": {
        "has_more_rows": false,
        "start_index": 1,
        "sort_field": "computer_system.service_tag",
        "fields_required": [
            "product_type",
            "operating_system.os",
            "ip_addresses",
            "vendor",
            "name",
            "computer_system.model",
            "org_serial_number",
            "state",
            "purchase_cost",
            "department",
            "user",
            "computer_system.service_tag",
            "icon",
            "ci",
            "operating_system.os",
            "last_success_audit"
        ]
,
        "total_count": 0,
        "filter_by": {
            "id": 1
        }
,
        "page": 1,
        "sort_order": "asc",
        "search_criteria": [
            {
                "condition": "contains",
                "field": "name",
                "logical_operator": "AND",
                "value": "test"
            }
,
            {
                "condition": "contains",
                "field": "product_type.name",
                "logical_operator": "AND",
                "value": "test"
            }

        ]
,
        "get_total_count": "true",
        "row_count": 0
    }

}

Postman示例

 

Python脚本示例

#Python version - 3.8
#This script requires requests module installed in python.
import requests
 
url = "https://localhost:8081/api/v3/assets"
headers ={"authtoken":"79A55158-2281-4F34-A64E-321EB809085F"}
input_data = '''{
    "list_info": {
        "row_count": "25",
        "get_total_count": true,
        "start_index": 1,
        "search_criteria": [
            {
                "field": "name",
                "value": "test",
                "condition": "contains",
                "logical_operator": "AND"
            },
            {
                "field": "product_type.name",
                "value": "test",
                "condition": "contains",
                "logical_operator": "AND"
            }
        ],
        "sort_field": "computer_system.service_tag",
        "sort_order": "asc",
        "filter_by": {
            "id": 1
        },
        "fields_required": [
            "product_type",
            "operating_system.os",
            "ip_addresses",
            "vendor",
            "name",
            "computer_system.model",
            "org_serial_number",
            "state",
            "purchase_cost",
            "department",
            "user",
            "computer_system.service_tag",
            "icon",
            "ci",
            "operating_system.os",
            "last_success_audit"
        ]
    }
}'''
params = {'input_data': input_data}
response = requests.get(url,headers=headers,params=params,verify=False)
print(response.text)



    • Related Articles

    • SDP SaaS API学习汇总

      DataCenter API Domain URL Accounts Server URL API Endpoint China https://servicedeskplus.cn https://accounts.zoho.com.cn https://servicedeskplus.cn/api/v3/requests 授权领牌/认证代码 - 认证服务器创建的临时领牌,用于客户端认证 访问领牌,执行API操作,时限1小时 刷新领牌,重新获取访问领牌 ...
    • 云版本认证API接口调用过程详解

      云版本认证API接口调用过程详解           云版本API接口调用认证较本地版更为复杂,参考如下文档进行云版本api接口调用。
    • 请求管理API字段详细信息表

      表 属性名 类型 details 描述 id long(Read Only) Id of this request 请求在数据库中存储的唯一标识 subject String Subject of this request 主题 description HTML Desc Description of this request 描述 short_description String A short description of this request 短描述 request_type ...
    • apm/opm 添加监视器 or 设备等常规api

      以apm为例,有些特殊情形下,监视器无法添加,无法删除等,但苦于没有及时有效的sql语句去操作,可以参考以下链接,从而排错,其他操作可查阅具体手册。 https://www.manageengine.cn/products/applications_manager/help/addmonitor-api.html opm也有丰富的api可操作设备,告警,组等供参考。 ...
    • 用API添加ci项时multi-line类型字段如何带格式?

      CMDB中的字段single-line最多显示250个字符,multi-line最多显示4000个字符,如果不加格式会在一行内显示。 有时客户希望多行文本中的值带一定格式,便于查看,比如说如下方式: 在调用API时,需要使用转码器将字符由ACSI转成Unicode即可,如下述所示,换行转码后是&#10;