From c315ecaef601eb4c1cf6fadd64f5203000d5d5f8 Mon Sep 17 00:00:00 2001 From: Iglocska Date: Thu, 30 Jul 2015 15:26:05 +0200 Subject: [PATCH] Fix to an issue with using XML as input for add_event() and update_event() - also a change to the copy_list.py script to account for the change --- examples/copy_list.py | 3 ++- pymisp/api.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/copy_list.py b/examples/copy_list.py index b7a1a55..16cb737 100644 --- a/examples/copy_list.py +++ b/examples/copy_list.py @@ -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 diff --git a/pymisp/api.py b/pymisp/api.py index edf047f..cc101d3 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -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): """