mirror of https://github.com/MISP/PyMISP
Merge pull request #11 from iglocska/xml_json_fix
Fix to an issue with using XML as input for add_event() and update_ev…pull/2/merge
commit
389f88ce8b
|
@ -4,6 +4,7 @@
|
|||
import sys
|
||||
|
||||
from pymisp import PyMISP
|
||||
import json
|
||||
|
||||
from keys import cert, priv
|
||||
|
||||
|
@ -30,7 +31,7 @@ def init(cert_to_priv=True):
|
|||
def _to_utf8(request):
|
||||
to_return = None
|
||||
if 'json' in request.headers['content-type']:
|
||||
to_return = request.json()
|
||||
to_return = json.dumps(request.json())
|
||||
else:
|
||||
to_return = request.text.encode('utf-8')
|
||||
return to_return
|
||||
|
|
|
@ -84,7 +84,7 @@ class PyMISP(object):
|
|||
:param event: Event object to add
|
||||
"""
|
||||
session = self.__prepare_session()
|
||||
return session.post(self.url, data=json.dumps(event))
|
||||
return session.post(self.url, data=event)
|
||||
|
||||
def update_event(self, event_id, event):
|
||||
"""
|
||||
|
@ -94,7 +94,7 @@ class PyMISP(object):
|
|||
:param event: Elements to add
|
||||
"""
|
||||
session = self.__prepare_session()
|
||||
return session.post(self.rest.format(event_id), data=json.dumps(event))
|
||||
return session.post(self.rest.format(event_id), data=event)
|
||||
|
||||
def delete_event(self, event_id):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue