Building for the Splunk Platform

How do I format the _key with splunk-python-sdk KVStoreCollectionData.insert data parameter?


I am sending an insert request via the splunk-python-sdk using the class splunklib.client.KVStoreCollectionData(collection) described here: But I am throwing an error that is inconsistent with the documentation. Does the insert method require a specific syntax for the _id pair?

The reference documentation for the insert method states, "...An _id field will be generated if not assigned in the data."

When I try to insert a new record with a populated _id field, however, I get a stack trace.

Here is my abbreviated code:

        kvStoreConn = client.connect(**kwargs)
        print("Connected to KVStore Successfully")
        collection = kvStoreConn.kvstore[props.get('dcCollection')]
        kvData =
    except AuthenticationError:
        print("Failed to connect")

    for record in allRecords:
        recID = record.get('_id')
        kvRecord = 'None'
        except splunklib.binding.HTTPError as herror:
            print ('Found HTTPError: ', herror)
            print('No record found.')

My print methods return this:

Found HTTPError:  HTTP 400 Bad Request -- The _id field is a reserved field and may not be present in a document or query.
No record found.

My POST looks like this [edited for clarity]

  "_id": "5bb27674d6a97e32ed36fc82",
  "submissionName": "U.S. Voluntary Green Power Market Data 2017",
  "abstract": "This data book provides certain data behind figures and tables found in the NREL report Status and Trends in the U.S. Voluntary Green Power Market 2017 Data. These data reflect estimates based on the best available data.",
  "sectors": [
    "Solar Power",
    "Wind Energy"
  "disciplines": [
    "Solar Energy"
  "nrelCenter": "6A20",
  "publisher": "National Renewable Energy Laboratory",
  "fundingOrganization": "DOE",
  "projectTitle": "Green Power Markets",
  "fundingOffice": "Office of Strategic Programs (EE-SP)",
  "projectNumber": "GO28308",
  "pubId": "72204",
  "hasConsent": "1",
 "moratorium": "2018-10-07 18:00:00",
  "keywords": [
    "green power sales",
    "energy certificates",
    "community solar",
  "created": "2018-10-01 13:33:08",
  "publicationDate": "2018-10-01 13:33:08",
  "updated": [
    "2018-10-08 10:10:15",
    "2018-10-08 10:09:53"
  "status": "Publicly accessible",
  "appName": "dc",
  "userId": "user",
  "submitted": "2018-10-01 14:01:06",
  "DOI": "10.7799/1476631"
0 Karma
Get Updates on the Splunk Community!

Splunk Training for All: Meet Aspiring Cybersecurity Analyst, Marc Alicea

Splunk Education believes in the value of training and certification in today’s rapidly-changing data-driven ...

Investigate Security and Threat Detection with VirusTotal and Splunk Integration

As security threats and their complexities surge, security analysts deal with increased challenges and ...

Observability Highlights | January 2023 Newsletter

 January 2023New Product Releases Splunk Network Explorer for Infrastructure MonitoringSplunk unveils Network ...