Deployment Architecture
Highlighted

Why am I getting error "Cannot perform action "POST" without a target name to act on" trying to add a server to a serverclass via REST API?

Champion

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>
0 Karma
Highlighted

Re: Why am I getting error "Cannot perform action "POST" without a target name to act on" trying to add a server to a serverclass via REST API?

Champion

Anyone? I'm looking for a way to use the REST API to add a server to an existing serverclass.

0 Karma
Highlighted

Re: Why am I getting error "Cannot perform action "POST" without a target name to act on" trying to add a server to a serverclass via REST API?

Ultra Champion

(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...

0 Karma
Highlighted

Re: Why am I getting error "Cannot perform action "POST" without a target name to act on" trying to add a server to a serverclass via REST API?

Champion

If I try it with the -d name=scappsombra, 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>
0 Karma
Highlighted

Re: Why am I getting error "Cannot perform action "POST" without a target name to act on" trying to add a server to a serverclass via REST API?

Contributor
0 Karma
Highlighted

Re: Why am I getting error "Cannot perform action "POST" without a target name to act on" trying to add a server to a serverclass via REST API?

SplunkTrust
SplunkTrust

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.