使用curl命令通过restapi创建项
我通过configitem模块在OTRS中配置了以下CMDB类结构:使用curl命令通过restapi创建项,rest,curl,otrs,cmdb,Rest,Curl,Otrs,Cmdb,我通过configitem模块在OTRS中配置了以下CMDB类结构: [ { Key => 'Field1', Name => 'Name1', Searchable => 1, Input => { Type => 'Text', Size => 50, MaxLength => 50, Requ
[
{
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,
},
},
];
我正试图通过REST-API(正确配置)创建一个新的配置项,其curl如下:
卷曲
""
-H“内容类型:应用程序/json”-d“{\”配置项\“:{\”类\“:\”类\“名称\”,
\“Name\”:“ci\u Name\”,“CIXMLData\”:{“Field1\”:“text\u value\u for_Field1\”,“Field2\”:“text\u value\u for_Field2\”}}”
-X柱
但服务器回答500个内部服务器错误:
<!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>
500内部服务器错误
内部服务器错误
服务器遇到内部错误或错误
配置错误,无法完成
你的要求
请通过以下地址与服务器管理员联系:
root@localhost要通知他们此错误发生的时间,
以及您在此错误之前执行的操作
有关此错误的详细信息,请参阅
在服务器错误日志中
如果“Field2”不是必填字段,并且我执行以下curl:
卷曲
""
-H“内容类型:应用程序/json”-d“{\”配置项\“:{\”类\“:\”类\“名称\”,
\“名称\:\“ci\U名称\”,“CIXMLData\”:{“字段1\”:“文本\U值\U用于字段1\”}}”
-X柱
该项是正确创建的,但是,如果尽管不是必需的,但我将一些值赋给Field2,则返回500错误
由于Field2有一些子字段(即使它们不是必需的),我认为我的curl中有一些语法错误
注意:当我使用相同的数据通过GUI创建CI时,它是正确创建的。可能有,但5xx意味着它不应该在客户机代码中修复,但在服务器代码中有需要修复的东西。当是客户端的错误时,服务器应该做出4xx的响应。请联系服务器开发人员以了解it@hanshenrik我也考虑过这一点,但我不明白为什么在我避免发送Field2(配置为非必需时)时,CI是正确创建的。这使我放弃了服务器端的任何问题。