Knowledge Management

How can I set KV store collection data for data type time, when using the REST API?

danrb1978
New Member

I am having trouble setting the value of a KV Store collection field of type time. Does anyone know the best way to do this through the REST API?

Some additional detail,

I have a KV Store collection, created through the REST API, which contains the following fields, with these types.

<s:key name="field.customerId">string</s:key>
<s:key name="field.notes">string</s:key>
<s:key name="field.expiration">time</s:key>

Next, I do a POST to my collection, with the following data:
{
"customerId":"123456",
"notes":"Expiration date should be 6/1/2016",
"expiration":"2016-06-01T12:00:00.000Z"
}

Last, I check the contents of the record:
{
"customerId": "123456",
"notes": "Expiration date should be 6/1/2016"
}

For some reason my expiration field won't persist data. I have taken a few guesses at the format required for my time field in the POST above, but have not had any success storing a value.

0 Karma

shaskell_splunk
Splunk Employee
Splunk Employee

You need to use a valid BSON data type and 'time' is not valid. Have a look at these two and see if either work.

https://docs.mongodb.org/manual/reference/bson-types/#date

https://docs.mongodb.org/manual/reference/bson-types/#timestamps

I believe you'll need to convert your date to epoch time as well.

eval epoch=strptime(expiration, "%Y-%m-%dT%H:%M:%S.%3NZ")

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Persistent Queue at TcpOut — One of Splunk's Most Practical Features

Splunk introduced persistent queueing at the tcpout layer as one of the most practical resilience features in ...

Skip the Awkward Silence: Have a .conf-ersation at .conf26

Picture this. You arrive at .conf26 already having your socializing and networking plans mapped out. No ...

Rethinking Zero Trust: From Product Purchases to Logical Control Evidence

Implementing Zero Trust (ZT) across complex environments often falters at the very beginning due to a ...