Add IT-Assets with CMDB API

Add IT-Assets with CMDB API

Good day,

i need to add multiple IT Assets through the CMDB API with the PowerShell Invoke-RestMethod.
I'm currently trying to connect and add very basic workstation

  1. $url    =   "https://XXX.XXX.XXX.XXX/api/cmdb/ci/"
  2. [xml]$input_data     =   Get-Content -Path 'c:\Scripts\workstation.xml'
  3. $body = @{
        OPERATION_NAME  = 'add';
        TECHNICIAN_KEY  = 'XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX';
        format          = 'xml';
        INPUT_DATA      = $input_data;
    }
  4. [xml]$return = Invoke-RestMethod -Uri $url -Method Post -Headers $header -Body $body
  5. $return.OuterXml
Its very similar to the phyton example in the documentation 

I always get the following response from the API:

<?xml version="1.0" encoding="UTF-8"?>
<API version="1.0">
<response>
<operation name="add">
<result>
<statuscode>3001</statuscode>
<status>Unbekannter Fehler.</status>
<message>Error when processing request - A JSONObject text must begin with '{' at 1 [character 2 line 1]</message>
</result>
</operation>
</response>
</API>

I have no idea what's the problem and have been testing for days now.
i would be very thankful for any help.


The Workstation.xml looks like this, basicly copied first line from the documentation and validated it with w3schools validator

<?xml version='1.0' encoding='UTF-8'?>
<API version='1.0' locale='en'>
<records>
<record>
<parameter><name>CI Name</name><value>sdp-w2k3-2</value></parameter>
<parameter><name>CI Type</name><value>Windows Workstation</value></parameter>
<parameter><name>Product Name</name><value>Latitude Optimus</value></parameter>
</record>
</records>
</API>

                  New to ADSelfService Plus?