0

I have the following CMDB class structure configured in OTRS via configitem module:

[
{ 
        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, 
        }, 
    },  
];

I am trying to create a new Configuration Item via REST-API (properly configured) with the following curl:

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 POST

But the server answers with 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>

If "Field2" is not a required field and I execute the following curl:

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\"}}}" -X POST

The item is properly created, however, if despite of not being required, I assign some value to Field2, then 500 error is given back.

As Field2 has some sub-fields (even when they are not required ones), I think that there is some syntax mistake in my curl.

NOTE: When I create the CI via GUI with the same data, it is properly created.

Zumo de Vidrio
  • 2,021
  • 2
  • 15
  • 33
  • perhaps there is, but 5xx means it's not something that should be fixed in the client code, but there's something to fix in the server code. when it's the client's fault, the server should respond 4xx-something. contact the server devs about it – hanshenrik Apr 24 '18 at 13:09
  • @hanshenrik I thought about it as well, but then I couldn't understand why when I avoid sending Field2 (when configured as not required) the CI was properly created. That made me discard any issue from server side. – Zumo de Vidrio Apr 25 '18 at 07:26

0 Answers0