<?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 Re: RESTful api output_mode of POST in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/RESTful-api-output-mode-of-POST/m-p/20578#M171</link>
    <description>&lt;P&gt;Thanks for your responses!  &lt;/P&gt;

&lt;P&gt;IMO, that's kinda silly.  Being that it's mentioned that JSON is an acceptable response format, I'd expect all the responses to be in JSON if that's what I ask for.  Mixing XML and JSON is fugly and I'm not gonna do it &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 30 Jul 2010 23:31:08 GMT</pubDate>
    <dc:creator>benjaminws</dc:creator>
    <dc:date>2010-07-30T23:31:08Z</dc:date>
    <item>
      <title>RESTful api output_mode of POST</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/RESTful-api-output-mode-of-POST/m-p/20573#M166</link>
      <description>&lt;P&gt;I see that I can set the output_mode on a GET request to be JSON, but I'd like the same to happen with a POST.  Currently it seems that if there is an error on a POST, it returns XML by default, &lt;STRIKE&gt;ignoring the output_mode query string.&lt;/STRIKE&gt; ignoring the output_mode value in the body..&lt;/P&gt;

&lt;P&gt;Here is some quick example code in python..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;bsmith@bsmith-laptop!1095 S:0 M:command
-&amp;gt; python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
&amp;gt;&amp;gt;&amp;gt; import httplib2
&amp;gt;&amp;gt;&amp;gt; import urllib
&amp;gt;&amp;gt;&amp;gt; 
&amp;gt;&amp;gt;&amp;gt; http_obj = httplib2.Http()
&amp;gt;&amp;gt;&amp;gt; encoded_body = urllib.urlencode({'username':'admin', 'password':'WRONGPASSWORD', 'output_type': 'JSON'})
&amp;gt;&amp;gt;&amp;gt; response = http_obj.request('https://localhost:8089/services/auth/login',
...                             'POST', headers={}, body=encoded_body)
&amp;gt;&amp;gt;&amp;gt; 
&amp;gt;&amp;gt;&amp;gt; print response
({'status': '401', 'content-length': '81', 'server': 'Splunkd', 'connection': 'close', 'date': 'Fri, 30 Jul 2010 16:26:01 GMT', 'content-type': 'text/xml; charset=utf-8'}, '&amp;lt;response&amp;gt;\n&amp;lt;messages&amp;gt;\n&amp;lt;msg type="WARN"&amp;gt;Login failed&amp;lt;/msg&amp;gt;\n&amp;lt;/messages&amp;gt;\n&amp;lt;/response&amp;gt;')
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also, I wanted to mention that it would be &lt;EM&gt;really&lt;/EM&gt; cool if you could specify an Accept header as opposed to a query string for output_mode..  It would go like this..&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;Accept: application/json&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;or&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;Accept: text/xml&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jul 2010 00:19:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/RESTful-api-output-mode-of-POST/m-p/20573#M166</guid>
      <dc:creator>benjaminws</dc:creator>
      <dc:date>2010-07-27T00:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: RESTful api output_mode of POST</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/RESTful-api-output-mode-of-POST/m-p/20574#M167</link>
      <description>&lt;P&gt;Is that really a post request when you do "?output_type=json"?&lt;/P&gt;

&lt;P&gt;But beyond that I don't see an difference in the output when I repeat the request with GET, and I am also not finding any docs on getting json responses back from the auth service?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2010 22:58:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/RESTful-api-output-mode-of-POST/m-p/20574#M167</guid>
      <dc:creator>goosemo</dc:creator>
      <dc:date>2010-07-30T22:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: RESTful api output_mode of POST</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/RESTful-api-output-mode-of-POST/m-p/20575#M168</link>
      <description>&lt;P&gt;Meh, that was left over from a get.  Nothing to see there ;).&lt;/P&gt;

&lt;P&gt;I would assume in a POST that it would accept headers of some sort..&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2010 23:16:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/RESTful-api-output-mode-of-POST/m-p/20575#M168</guid>
      <dc:creator>benjaminws</dc:creator>
      <dc:date>2010-07-30T23:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: RESTful api output_mode of POST</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/RESTful-api-output-mode-of-POST/m-p/20576#M169</link>
      <description>&lt;P&gt;Yeah, its all in a few files. The response itself is made by the  generateError() in splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/controllers/proxy.py&lt;/P&gt;

&lt;P&gt;But I don't really know a good way to edit that to make it know when to make json errors. And I don't know if/how that'd break the chain back.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2010 23:21:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/RESTful-api-output-mode-of-POST/m-p/20576#M169</guid>
      <dc:creator>goosemo</dc:creator>
      <dc:date>2010-07-30T23:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: RESTful api output_mode of POST</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/RESTful-api-output-mode-of-POST/m-p/20577#M170</link>
      <description>&lt;P&gt;Also in looking though the code, the only things the auth seems to expect in the header is username and password.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2010 23:27:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/RESTful-api-output-mode-of-POST/m-p/20577#M170</guid>
      <dc:creator>goosemo</dc:creator>
      <dc:date>2010-07-30T23:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: RESTful api output_mode of POST</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/RESTful-api-output-mode-of-POST/m-p/20578#M171</link>
      <description>&lt;P&gt;Thanks for your responses!  &lt;/P&gt;

&lt;P&gt;IMO, that's kinda silly.  Being that it's mentioned that JSON is an acceptable response format, I'd expect all the responses to be in JSON if that's what I ask for.  Mixing XML and JSON is fugly and I'm not gonna do it &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2010 23:31:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/RESTful-api-output-mode-of-POST/m-p/20578#M171</guid>
      <dc:creator>benjaminws</dc:creator>
      <dc:date>2010-07-30T23:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: RESTful api output_mode of POST</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/RESTful-api-output-mode-of-POST/m-p/20579#M172</link>
      <description>&lt;P&gt;The response you are getting is from the simpleRequest method which states:&lt;BR /&gt;
This method will return a tuple of (serverResponse, serverContent)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    serverResponse: a dict of HTTP status information
    serverContent: the body content
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So that first bit isn't even json it seems, but a plain python dict.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2010 23:55:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/RESTful-api-output-mode-of-POST/m-p/20579#M172</guid>
      <dc:creator>goosemo</dc:creator>
      <dc:date>2010-07-30T23:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: RESTful api output_mode of POST</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/RESTful-api-output-mode-of-POST/m-p/20580#M173</link>
      <description>&lt;P&gt;Right, I am assuming the rest of the response (the XML) is the response body.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2010 23:58:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/RESTful-api-output-mode-of-POST/m-p/20580#M173</guid>
      <dc:creator>benjaminws</dc:creator>
      <dc:date>2010-07-30T23:58:35Z</dc:date>
    </item>
  </channel>
</rss>

