I am trying to add to/delete from a key/value store I created called kvstore for an app called kvtest. The idea is the user enters info into a django form, and then through a post, a save view gets the user information and makes a call to kvstore's rest endpoint. However, every time I try out my code I get this error:
2015-02-23 12:42:12,516 ERROR runwsgiserver:185 - Internal Server Error: /dj/en-us/kvtest/save/
Traceback (most recent call last):
File "/Applications/Splunk/lib/python2.7/site-packages/django/core/handlers/base.py", line 115, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/Applications/Splunk/lib/python2.7/site-packages/django/contrib/auth/decorators.py", line 25, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/Applications/Splunk/etc/apps/kvtest/django/kvtest/views.py", line 52, in save
owner='nobody', app='kvtest')
File "/Applications/Splunk/etc/apps/framework/contrib/splunk-sdk-python/splunklib/binding.py", line 235, in wrapper
return request_fun(self, *args, **kwargs)
File "/Applications/Splunk/etc/apps/framework/contrib/splunk-sdk-python/splunklib/binding.py", line 61, in new_f
val = f(*args, **kwargs)
File "/Applications/Splunk/etc/apps/framework/contrib/splunk-sdk-python/splunklib/binding.py", line 719, in request
'body': body})
File "/Applications/Splunk/etc/apps/framework/contrib/splunk-sdk-python/splunklib/binding.py", line 1099, in request
raise HTTPError(response)
File "/Applications/Splunk/etc/apps/framework/contrib/splunk-sdk-python/splunklib/binding.py", line 879, in __init__
detail = XML(body).findtext("./messages/msg")
File "/Applications/Splunk/lib/python2.7/xml/etree/ElementTree.py", line 1300, in XML
parser.feed(text)
File "/Applications/Splunk/lib/python2.7/xml/etree/ElementTree.py", line 1642, in feed
self._raiseerror(v)
File "/Applications/Splunk/lib/python2.7/xml/etree/ElementTree.py", line 1506, in _raiseerror
raise err
ParseError: syntax error: line 1, column 0
:set nonu
Here is my view code:
def save(request):
service = request.service
headers = [('Content-Type', 'application/json')]
form = SetupForm(request.POST)
form.is_valid()
data = form.cleaned_data
payload = {
'name': data['name'],
'username': data['username'],
'interval': data['interval']
}
payload = json.dumps(payload)
r = service.request('/storage/collections/data/kvstore', method='POST', headers=headers, body=payload,
owner='nobody', app='kvtest')
return HttpResponseRedirect('/dj/en-us/kvtest/home/')
Everything works up until the service.request call, which is where the error seems to be coming from.
This is just a test, so ignore the lack of error checking, but I am at a loss as to what is going wrong.
... View more