我通过 configitem 模块在 OTRS 中配置了以下 CMDB 类结构:
[
{
Key => 'Field1',
Name => 'Name1',
Searchable => 1,
Input => {
Type => 'Text',
Size => 50,
MaxLength => 50, Required => 1,
}, {
Key => 'Field2',
Name => 'Name2',
Searchable => 1,
Input => {
Type => 'Text',
Size => 50,
MaxLength => 50, Required => 1,
},
Sub=>[ {
Key => 'Field2-1',
Name => 'Name2-1',
Searchable => 1,
Input => {
Type => 'Text',
Size => 50,
MaxLength => 50,
},
}, {
Key => 'Field2-2',
Name => 'Name2-2',
Searchable => 1,
Input => {
Type => 'Text',
Size => 50,
MaxLength => 50,
},
}, {
Key => 'Field2-3',
Name => 'Name2-3',
Searchable => 1,
Input => {
Type => 'Text',
Size => 50,
MaxLength => 50,
},
},
];
我正在尝试使用以下 curl 通过 REST-API(正确配置)创建一个新的配置项:
curl " http://url/nph-genericinterface.pl/Webservice/ws/ConfigItem?UserLogin=username&Password=password " -H "Content-Type: application/json" -d "{\"ConfigItem\":{\" Class\":\"class_name\", \"Name\":\"ci_name\",\"CIXMLData\":{\"Field1\":\"text_value_for_field1\",\"Field2\":\"text_value_for_field2 \"}}}" -X 发布
但是服务器以 500 Internal Server Error 回答:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator at
root@localhost to inform them of the time this error occurred,
and the actions you performed just before this error.</p>
<p>More information about this error may be available
in the server error log.</p>
</body></html>
如果“Field2”不是必填字段,我执行以下 curl:
curl " http://url/nph-genericinterface.pl/Webservice/ws/ConfigItem?UserLogin=username&Password=password " -H "Content-Type: application/json" -d "{\"ConfigItem\":{\"类\":\"class_name\", \"Name\":\"ci_name\",\"CIXMLData\":{\"Field1\":\"text_value_for_field1\"}}}" -X POST
该项目已正确创建,但是,如果尽管不需要,我为 Field2 分配了一些值,则返回 500 错误。
由于 Field2 有一些子字段(即使它们不是必需的),我认为我的 curl 中有一些语法错误。
注意:当我通过 GUI 使用相同的数据创建 CI 时,它会正确创建。