Getting Data In

Who can tell me why the API POST for JSON doc times out -

himynamesdave
Contributor

This DOES NOT work:

curl -k -u admin:changeme "https://0.0.0.0:8089/services/receivers/simple?source=mysource&index=myindex" -d {"somefield":"foobar”}

This DOES work:

curl -k -u admin:changeme "https://0.0.0.0:8089/services/receivers/simple?source=mysource&index=myindex" -d somefield=foobar

Looking at the docs (http://dev.splunk.com/view/SP-CAAADQT), I think this is hinting at why the first request is broken "The -d/--post-data arguments for curl/wget need to be url-encoded, should they have characters needing escaping."

Can someone tell me how a JSON data should be formatted to be submitted like this? Thanks!

Tags (3)
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

Sounds like a curl/shell issue to me. curl -d "string" means you want something like this:

curl ... -d "foo bar"

As a result, I'd guess passing JSON might look like this (untested):

curl ... -d "{\"somefield\":\"foobar\"}"

View solution in original post

martin_mueller
SplunkTrust
SplunkTrust

Sounds like a curl/shell issue to me. curl -d "string" means you want something like this:

curl ... -d "foo bar"

As a result, I'd guess passing JSON might look like this (untested):

curl ... -d "{\"somefield\":\"foobar\"}"

View solution in original post

Register for .conf21 Now! Go Vegas or Go Virtual!

How will you .conf21? You decide! Go in-person in Las Vegas, 10/18-10/21, or go online with .conf21 Virtual, 10/19-10/20.