<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Using HTML to execute a cURL command in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-HTML-to-execute-a-cURL-command/m-p/397728#M26025</link>
    <description>&lt;P&gt;Hello all,&lt;/P&gt;

&lt;P&gt;My ultimate goal is to have a button (or buttons) on a Splunk dashboard which will inform other users when they have left their desk. &lt;/P&gt;

&lt;P&gt;my current method is to add a clickable button using HTML on a HTML converted dashboard which will execute a cURL command.  The cURL command is used to send data via the HTTP Event Collector to an index which would have the latest status of each user.  I am able to execute the cURL command just fine with what I have below in the CLI:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;curl -k &lt;A href="https://&amp;lt;HOST&amp;gt;:8088/services/collector" target="test_blank"&gt;https://&amp;lt;HOST&amp;gt;:8088/services/collector&lt;/A&gt; -H 'Authorization: Splunk &amp;lt;TOKEN&amp;gt;' -d '{"sourcetype": "cURL", "event":"name=JOHN location=WEST status=OUT"}'&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I've attempted to convert the cURL command to an HTML form for the dashboard but what I'm using doesn't pass the HEC token properly: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;form ref='uploadForm' 
  id='uploadForm' 
 action='https://Splunk:&amp;lt;TOKEN&amp;gt;@&amp;lt;HOST&amp;gt;:8088/services/collector' 
  method='post' 
  encType="multipart/form-data"&amp;gt;
    &amp;lt;input type='hidden' type="location" name="West" value="West" /&amp;gt;
    &amp;lt;input type='hidden' type="name" name="John" value="John" /&amp;gt;
    &amp;lt;input type='hidden' type="status" name="Out" value="Out" /&amp;gt;
    &amp;lt;input type='submit' value='John is out' /&amp;gt;
&amp;lt;/form&amp;gt; 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When using the above HTML, I get the following error:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;{"text":"Token is required","code":2}&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;Any guidance on how to pass the HEC token or a more efficient method would be greatly appreciated.  &lt;/P&gt;</description>
    <pubDate>Thu, 09 Aug 2018 16:14:21 GMT</pubDate>
    <dc:creator>jpofosho</dc:creator>
    <dc:date>2018-08-09T16:14:21Z</dc:date>
    <item>
      <title>Using HTML to execute a cURL command</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-HTML-to-execute-a-cURL-command/m-p/397728#M26025</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;

&lt;P&gt;My ultimate goal is to have a button (or buttons) on a Splunk dashboard which will inform other users when they have left their desk. &lt;/P&gt;

&lt;P&gt;my current method is to add a clickable button using HTML on a HTML converted dashboard which will execute a cURL command.  The cURL command is used to send data via the HTTP Event Collector to an index which would have the latest status of each user.  I am able to execute the cURL command just fine with what I have below in the CLI:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;curl -k &lt;A href="https://&amp;lt;HOST&amp;gt;:8088/services/collector" target="test_blank"&gt;https://&amp;lt;HOST&amp;gt;:8088/services/collector&lt;/A&gt; -H 'Authorization: Splunk &amp;lt;TOKEN&amp;gt;' -d '{"sourcetype": "cURL", "event":"name=JOHN location=WEST status=OUT"}'&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I've attempted to convert the cURL command to an HTML form for the dashboard but what I'm using doesn't pass the HEC token properly: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;form ref='uploadForm' 
  id='uploadForm' 
 action='https://Splunk:&amp;lt;TOKEN&amp;gt;@&amp;lt;HOST&amp;gt;:8088/services/collector' 
  method='post' 
  encType="multipart/form-data"&amp;gt;
    &amp;lt;input type='hidden' type="location" name="West" value="West" /&amp;gt;
    &amp;lt;input type='hidden' type="name" name="John" value="John" /&amp;gt;
    &amp;lt;input type='hidden' type="status" name="Out" value="Out" /&amp;gt;
    &amp;lt;input type='submit' value='John is out' /&amp;gt;
&amp;lt;/form&amp;gt; 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When using the above HTML, I get the following error:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;{"text":"Token is required","code":2}&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;Any guidance on how to pass the HEC token or a more efficient method would be greatly appreciated.  &lt;/P&gt;</description>
      <pubDate>Thu, 09 Aug 2018 16:14:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Using-HTML-to-execute-a-cURL-command/m-p/397728#M26025</guid>
      <dc:creator>jpofosho</dc:creator>
      <dc:date>2018-08-09T16:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using HTML to execute a cURL command</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-HTML-to-execute-a-cURL-command/m-p/397729#M26026</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
This link could be of some use to embed curl command to HTML.&lt;BR /&gt;
&lt;A href="https://www.embedcurl.com/"&gt;https://www.embedcurl.com/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 13:13:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Using-HTML-to-execute-a-cURL-command/m-p/397729#M26026</guid>
      <dc:creator>sanagari</dc:creator>
      <dc:date>2019-01-21T13:13:17Z</dc:date>
    </item>
  </channel>
</rss>

