All Apps and Add-ons

TA-Webtools: How to add headers in a POST request ?

duuhsousa
New Member

Hi there!

I am trying to use TA-Webtools for start a automation flow. To do this I need to make a POST request as below

curl -k -X POST -H "Content-type: application/json" --data '{"flowUuid":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx","inputs":{"A1": "B1","A2":"B2"}}' "https://server:8080/xxx/rest/v2"

Using TA-Webtools I am using the search command below

<my search> | curl method=POST data="{'flowUuid':'xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'}" uri=https://server:8080/xx/rest/v2

This command isn't working because are missing the header "Content-type: application/json".

How can I include this?
I think that I need to edit the python scripts, but how ?

0 Karma

suser2019
Explorer

I am using this app https://splunkbase.splunk.com/app/4146
The curl command is not picking up method=POST and always returning error 405 and
{"error":{"detail":"GET method not supported for API","message":"Method not Supported"},"status":"failure"}

I used this command
| eval header="{\"Content-Type\":\"application/json\", \"Accept\":\"application/json\"}"
| curl method=post uri= user= pass= headerfield= header

Now I am not sure how to make a POST call to an external API from Splunk search. Every time it is being detected as GET.

0 Karma

jkat54
SplunkTrust
SplunkTrust
0 Karma

suser2019
Explorer

Testing the splunk add on for service-now app..

0 Karma

suser2019
Explorer

Got it working

0 Karma

jkat54
SplunkTrust
SplunkTrust

See this new app that goes well beyond my curl command: https://splunkbase.splunk.com/app/4172/

0 Karma

suser2019
Explorer

I was unable to make a POST using this application

0 Karma

jkat54
SplunkTrust
SplunkTrust

See release version 1.1.0

I couldnt make it work in the command like you wanted

     | curl data="JSON_DATA_HERE"

I had to make use of eval function to make the JSON field that gets passed to the request

     | makeresults count=1  | eval header="{\"content-type\":\"application/json\"}" | eval data="{\"test data\":None}" | curl uri=https://localhost:8089/services user=admin pass=changme debug=true headerfield=header datafield=data

Let me know how it works for you

https://splunkbase.splunk.com/app/4146/

0 Karma

jkat54
SplunkTrust
SplunkTrust

Can you let us know if this works for you?

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!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...