Captain
Captain
284 views

REST API to add remote servers

Hello, I am trying to use the REST API to add remote servers to my sitescope install. I followed the documentation and I am getting the error that my JSON is invalid on POST. I am not sure where I am going wrong, although I am just using curl at this point to get my request correct then move on to scripting it.

my curl request is `curl -XPOST -k "https://sitescope:8443/SiteScope/api/remoteserver/configdata" -H 'Content-Type: application/json' -d '@siteScopeTest'`

with the contents of file siteScopeTest being

{
  "RemoteServerConfig": [{
    "UNIX": [{
      "_host": "server01",
      "_name": "server01",
      "_os": "RHESLinux",
      "_disableCache": "",
      "_keyFile": "",
      "_password": "",
      "_sshAuthMethod": "password",
      "_sshConnectionsLimit": "3",
      "_remoteEncoding": "UTF-8",
      "_credentials": "1131488408",
      "_description": "",
      "_keepalive": "",
      "_login": "",
      "_version2": "true",
      "_trace": "",
      "_sshPort": "22",
      "_method": "ssh"
    }, {
      "_host": "server02",
      "_name": "server02",
      "_os": "RHESLinux",
      "_disableCache": "",
      "_keyFile": "",
      "_password": "",
      "_sshAuthMethod": "password",
      "_sshConnectionsLimit": "3",
      "_remoteEncoding": "UTF-8",
      "_credentials": "1131488408",
      "_description": "",
      "_keepalive": "",
      "_login": "",
      "_version2": "true",
      "_trace": "",
      "_sshPort": "22",
      "_method": "ssh"
    }, {
      "_name": "server03",
      "_host": "server03",
      "_os": "RHESLinux",
      "_disableCache": "",
      "_keyFile": "",
      "_password": "",
      "_sshAuthMethod": "password",
      "_sshConnectionsLimit": "3",
      "_remoteEncoding": "UTF-8",
      "_credentials": "1131488408",
      "_description": "",
      "_keepalive": "",
      "_login": "",
      "_version2": "true",
      "_trace": "",
      "_sshPort": "22",
      "_method": "ssh"
    }]
  }]
}

 

The response from the API call is Failed to import Remote Server Configuration. Invalid config file. and in the error.log file

 

ERROR - Failed to import Remote Server Configuration : java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2

Labels (1)
Tags (2)
0 Likes
1 Reply
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

Hello NickRad, 

I hope you are fine. 

Checking the information provided, I would like to know if you have tried the Postman tool to check the response and the functionality of the API. 

Best Regards, 

 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.