Closed sidsinhad closed 2 years ago
ok.
_load_sid(response) does a simple _load_atom(response), assuming that everything is XML. However, job creation follows the output_mode and the response is actually JSON in this case, eg: b'{"sid":"1574422392.8448_AAB56AC3-E7E0-4CF6-A072-3CB90850813D"}'
I've hacked around it for now myself by doing:
def _load_sid(response, output_mode="xml"): if output_mode.lower().startswith('json'): response_json = response.body.read().decode("utf-8") return json.loads(response_json)["sid"] return _load_atom(response).response.sid
and changing the two call sites to: sid = _load_sid(response, output_mode=kwargs.get('output_mode', 'xml'))
And then realized that the results() call comes back with XML by default. So I'd recommend: don't change the code for the search; specify output_mode='json' when calling job.results(output_mode='json')
@sidsinhad we have addressed this issue and the fix will be available in the next release. PR for reference :- https://github.com/splunk/splunk-sdk-python/pull/447 Please let us know if you are still facing the issue.
@sidsinhad we would request you to use the latest SDK release. We have implemented the fix and is available in the latest SDK release. Please let us know if you still face the issue.
I am trying to export splunk result into json format using splunk sdk. Below is the code I am using, this works when output_mode is csv, but when I use json, it fails with the error mentioned below.
Below error:
I updated the sdk version to 1.6.11, still the same.