Getting Data In

ERROR ExecProcessor - message from "script.py" Error: cannot serialize {json}

manudbc
Explorer

Hi,
I have a Script which download a Json, it look like:
def stream_events(self, inputs, ew):
ew.log("INFO","Adding data")
for input_name, input_item in inputs.inputs.iteritems():
api = input_item["api"]

                        try:
                                r = requests.get("URL".format(api))
                                t = json.loads(r.content)
                        except Exception as e:
                                ew.log("ERROR", "Error: %s" % str(e))

                        try:
                                for elements in t['notifications']:
                                        logevent = Event()
                                        logevent.stanza = input_name
                                        logevent.data = elements
                                        ew.write_event(logevent)
                        except Exception as e:
                                ew.log("ERROR", "Error: %s" % str(e))

And I having thaths error in index= "__internals":
ERROR ExecProcessor - message from "script.py" Error: cannot serialize {json}

How can I solve It?

Tags (2)
0 Karma
1 Solution

manudbc
Explorer

Solved
It was a problem in this line:
logevent.data = elements

Solved line:
logevent.data = json.dumps(elements, sort_keys=True, separators=(',',':'))

View solution in original post

0 Karma

manudbc
Explorer

Solved
It was a problem in this line:
logevent.data = elements

Solved line:
logevent.data = json.dumps(elements, sort_keys=True, separators=(',',':'))

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...