Hi,
I'm trying to add a server to a serverclass using the REST API, but getting an error. Can someone help me?
curl -k -u admin:password https://myserver.fmr.com:8089/services/deployment/server/serverclasses -X POST -d '{ "name" => "sc_apps_ombra", "whitelist.0" => "1.2.3.4" }'
I get the following:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<messages>
<msg type="ERROR">
In handler 'serverclasses': Cannot perform action "POST" without a target name to act on.</msg>
</messages>
</response>
(Recap of what you and I emailed to each other - sharing for other's knowledge here on answers).
Super glad to see you’re playing with the REST API. Very advanced stuff!
I would avoid using the –X POST
and then json format. I’ve never seen that before (but am interested in learning it if that’s a new thang).
The way I’ve done this in the past, which works right now on my local, is to use the –d flags for each attribute:
curl -k -u admin:password https://hostname:port/services/deployment/server/serverclasses -d name=sc_apps_ombra -d whitelist.0=1.2.3.4
The docs for it are here:
http://docs.splunk.com/Documentation/Splunk/6.2.6/RESTREF/RESTdeploy#deployment.2Fserver.2Fservercla...
In general with the REST API, if you want to edit an object, you’d use the endpoint for that specific object. That’s documented in the next item on the same page: http://docs.splunk.com/Documentation/Splunk/6.2.6/RESTREF/RESTdeploy#deployment.2Fserver.2Fservercla...
Just a note to any Splunk app developers who might see this error and land here.
In general this message means that a POST failed to specify the "name" of the stanza in the payload.
And in turn one way this can be easy to hit, is if you're using en.Entity() to create a new stanza but forgetting to list the stanza name as an explicit "name" arg in the payload.
If I try it with the -d name=sc_apps_ombra, then Splunk complains the serverclass already exists. If I try https://hostname:port/services/deployment/server/server/sc_apps_ombra -d whitelist.0=1.2.3.4, then I get:
<messages>
<msg type="ERROR">
In handler 'serverclasses': bundle=serverclass stanza=serverClass:sc_apps_ombra The sourceApp=system doesn't equal callerApp=search</msg>
</messages>
</response>
a212830: I had the same problem, and resolved it. See https://answers.splunk.com/answers/411823/unable-to-manipulate-serverclass-whitelist-via-res.html#an...
Anyone? I'm looking for a way to use the REST API to add a server to an existing serverclass.