Which version of splunk python sdk are you using?
I used this script to verify python sdk using latest from https://github.com/splunk/splunk-sdk-python
from splunklib.binding import httperror
import splunklib.client as client
import splunklib.results as results
import json
# admin user settings
splunk_user = 'admin'
splunk_pswd = 'changeme'
splunk_host = 'localhost'
splunk_port = 8089
splunk_app = 'search'
splunk_owner = 'nobody'
collections_conf_endpoint = 'storage/collections/config/'
collections_data_endpoint = 'storage/collections/data/'
collection_name = 'kvstore'
admin_service = client.connect(
host = splunk_host,
port = splunk_port,
username = splunk_user,
password = splunk_pswd,
app = splunk_app,
owner = splunk_owner
)
payload = {
'name': 'name',
'username': 'username',
'interval': 'interval'
}
payload = json.dumps(payload)
# as an 'nobody' add data to the kv store (app 'search')
request2 = admin_service.request(
collections_data_endpoint + collection_name,
method='post',
headers=[('content-type', 'application/json')],
body=payload,
owner='nobody',
app='search'
)
print request2
it is working as expected
$ python kvstore.py
{'status': 201, 'headers': [('content-length', '35'), ('cache-control', 'no-store, no-cache, must-revalidate, max-age=0'), ('content-type', 'application/json; charset=UTF-8'), ('x-content-type-options', 'nosniff'), ('expires', 'Thu, 26 Oct 1978 00:00:00 GMT'), ('date', 'Tue, 24 Feb 2015 17:15:16 GMT'), ('server', 'Splunkd'), ('connection', 'Close'), ('vary', 'Authorization'), ('x-frame-options', 'SAMEORIGIN')], 'reason': 'Created', 'body': <splunklib.binding.ResponseReader object at 0x10abf2f50>}
After that I verified that objects are exist (I run this script manually few times, so I have more than one object)
$ curl -k -u admin:changeme https://outcoldx:8089/servicesNS/nobody/search/storage/collections/data/kvstore/
[ { "username" : "Username", "interval" : "Interval", "name" : "Name", "_user" : "nobody", "_key" : "54ecb0e22dbbb62b95054241" }, { "interval" : "Interval", "username" : "Username", "name" : "Name", "_user" : "nobody", "_key" : "54ecb1a42dbbb62b95054242" } ]%
... View more