Getting Data In
Highlighted

How do I import json module?

Contributor

i am trying to write a python script to get data from a external API.
When I execute the script in Splunk, it fails on json.

The basic format of the script is -

import sys
import requests
import json
import splunk.Intersplunk as si
.
.
.

token_url = base_url+'/security/getToken'
payload = {'xxx': key,'yyy': user,'zzz': pwd}
r = requests.post(token_url, json = payload)
token = r.text.replace('"',"")

How do I import the json module?

0 Karma
Highlighted

Re: How do I import json module?

Contributor

To solve this problem, I set up a Windows bat file to execute a .py file that saves the data into a json file on the local drive. Splunk monitors this file without any issues.

View solution in original post

0 Karma