All Apps and Add-ons

curl command not working may be a format issue - webtools addon

ansif
Motivator

Unable to run curl from Splunk search.

Working fine from ssh session:

 

-bash-4.2$ curl -k -u admin:xxxxxxx https://localhost:8089/servicesNS/nobody/SA-ITOA/maintenance_services_interface/maintenance_calendar -X POST -H "Content-Type:application/json" -d '{"title":"TEST MW","start_time":"1591814852.152","end_time":"1592814852.364","objects": [{"object_type": "entity", "_key": "e7002b20-6b38-49ec-ad2a-29a0be0d2d65"}]}'

{"_key": "5ee1d57e5575d4d6ee5710d1"}


But below search throws error:

 

index=_internal
| head 1
| eval header="{\"content-type\":\"application/json\"}"
| eval data="{\"title\":\"TEST MW\",\"start_time\":\"1591814852.152\",\"end_time\":\"1592814852.364\",\"objects\":[{\"object_type\":\"entity\",\"_key\":\"e7002b20-6b38-49ec-ad2a-29a0be0d2d65\"}]}"
| curl method=post uri=https://localhost:8089/servicesNS/nobody/SA-ITOA/maintenance_services_interface/maintenance_calendar splunkauth=true debug=true headerfield=header datafield=data

 

Please help.

Labels (2)
0 Karma

jkat54
SplunkTrust
SplunkTrust

have you tried to URLENCODE your message?

have you tried validating your json?

The error is saying that the fields are improperly defined.  Most likely due to bad encoding or escaping.

0 Karma

Tune In & Win!

Don't miss out on your
chance to take home free
prizes by helping our players
save the Splunk Cloudom!

Dungeons & Data
Monsters: Splunk O11y
Day Editions Games
stream live:
5/4 at 6:30pm PST
5/5 at 7:00pm PST
on