# 使用条件获取CI明细

要使用条件获取CI明细，请使用以下URL格式：

http://<hostname>:<port>/api/cmdb/ci/

假设您想使用某种形式的标准来读取与端口号8080的本地服务器相关联的CI的详细信息，则URL应指定为：

http://localhost:8080/api/cmdb/ci/

关键点：

1. 输入是以密钥"INPUT_DATA"作为"POST attribute"发送的XML字符串。

2. 操作名"read"应通过密钥"OPERATION_NAME"作为"POST attribute"发送。

3. 技术员密钥应通过密钥"TECHNICIAN_KEY"作为"POST attribute"发送。

| 注意事项： 如果未指定结果格式，则API将以 JSON 格式返回输出。 参数 Result Format - Optional 指定返回格式（XML或JSON），如果未指定返回格式，则API将以JSON格式返回输出。

使用各种条件的XML输入示例：

1. 使用条件运算符和关系运算符（OR）获取CI详细信息

2. 使用日期条件获取配置项详细信息

- XML应答示例

- JSON应答示例

使用条件和关系运算符获取CI详细信息（或）

> > > > <API version="1.0" locale="en"> <criterias> <criteria> <parameter> <name compOperator="START WITH">CI Type</name> <!-- Can give Non english values in the parameter names as well as in the data--> <value>Windows Workstation</value> </parameter> <reloperator>OR</reloperator> <parameter> <name compOperator="CONTAINS">CI Name</name> <value>sdp</value> </parameter> </criteria> </criterias> <returnFields> <name>CI Name</name> <name>CI Type</name> <name>Business Impact</name> <name>Site</name> <name>Description</name> </returnFields> <sortparameters sortOrder="desc"> <name>CI Name</name> <name>Site</name> </sortparameters> <!-- If the total number pages is 100, we can give the navigation from 50 to 50 --> <range> <startindex>1</startindex> <limit>50</limit> </range> </API>

使用条件和关系运算符获取CI详细信息（或）

> > > > <?xml version="1.0" encoding="UTF-8"?> <API version="1.0"> <citype> <name>Workstation</name> <criterias> <criteria> <parameter> <name compOperator="IS">Acquisition Date</name> <value>2011-12-30</value> </parameter> </criteria> </criterias> <returnFields> <!-- Syntax to return all available column(s). <name>*</name> --> <name>CI Name</name> <name>CI Type</name> <name>Owned By</name> <name>Site</name> <name>Description</name> <name>Acquisition Date</name> <name>Warranty Expiry Date</name> <name>Expiry Date</name> <name>Asset Tag</name> <name>Serial Number</name> <name>Barcode</name> <name>Product Name</name> <name>Resource State</name> <name>Vendor</name> <name>Location</name> <name>Mac Address</name> <name>WS UDF Date</name> <name>WS UDF Num</name> <name>WS UDF Multi</name> <name>WS UDF String</name> <name>Sites</name> </returnFields> <sortFields sortOrder="desc"> <name>Product Name</name> </sortFields> </citype> </API>

XML应答示例(删节)

> > > > <?xml version="1.0" encoding="UTF-8"?> <API locale="en" version="1.0"> <response> <range> <startindex>40</startindex> <limit>50</limit> </range> <result> <statuscode>200</statuscode> <status>Success</status> <message>Successfully fetched.</message> <created-date>May 10, 2013 12:52 PM</created-date> <field-names> <name type="String">CI Name</name> <name type="String">CI Type</name> <name type="String">Site</name> <name type="String">Description</name> </field-names> <field-values totalRecords="14"> <record> <value>21 (hp2650.csez.zohocorpin.com)</value> <value>Switch Ports</value> <value>(null)</value> <value>Created while scanning..</value> </record> <!-- Truncated . . . --> <record> <value>10 (hp2650.csez.zohocorpin.com)</value> <value>Switch Ports</value> <value>(null)</value> <value>Created while scanning..</value> </record> <record> <value>1 (hp2650.csez.zohocorpin.com)</value> <value>Switch Ports</value> <value>(null)</value> <value>Created while scanning..</value> </record> </field-values> </result> </response> </API>

JSON应答示例

{"API":{"locale":"en","response":{"":{"result":{"created-date":"May 10, 2013 12:55 PM","field-names":{"name":[{"type":"String","content":"CI Name"},{"type":"String","content":"CI Type"},{"type":"String","content":"Site"},{"type":"String","content":"Description"}]},"message":"Successfully fetched.","field-values":{"record":[{"value":["21 (hp2650.csez.zohocorpin.com)","Switch Ports","(null)","Created while scanning.."]},{"value":["20 (hp2650.csez.zohocorpin.com)","Switch Ports","(null)","Created while scanning.."]},{"value":["2 (hp2650.csez.zohocorpin.com)","Switch Ports","(null)","Created while scanning.."]},{"value":["19 (hp2650.csez.zohocorpin.com)","Switch Ports","(null)","Created while scanning.."]},{"value":["18 (hp2650.csez.zohocorpin.com)","Switch Ports","(null)","Created while scanning.."]},{"value":["17 (hp2650.csez.zohocorpin.com)","Switch Ports","(null)","Created while scanning.."]},{"value":["16 (hp2650.csez.zohocorpin.com)","Switch Ports","(null)","Created while scanning.."]},{"value":["15 (hp2650.csez.zohocorpin.com)","Switch Ports","(null)","Created while scanning.."]},{"value":["14 (hp2650.csez.zohocorpin.com)","Switch Ports","(null)","Created while scanning.."]},{"value":["13 (hp2650.csez.zohocorpin.com)","Switch Ports","(null)","Created while scanning.."]},{"value":["12 (hp2650.csez.zohocorpin.com)","Switch Ports","(null)","Created while scanning.."]},{"value":["11 (hp2650.csez.zohocorpin.com)","Switch Ports","(null)","Created while scanning.."]},{"value":["10 (hp2650.csez.zohocorpin.com)","Switch Ports","(null)","Created while scanning.."]},{"value":["1 (hp2650.csez.zohocorpin.com)","Switch Ports","(null)","Created while scanning.."]}],"totalRecords":"14"},"status":"Success","statuscode":"200"},"range":{"limit":"50","startindex":"40"},"name":"read"}},"version":"1.0"}}