Getting Data In

How do I import json module?

scottrunyon
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
1 Solution

scottrunyon
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

scottrunyon
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.

0 Karma
Get Updates on the Splunk Community!

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...