I have a RESTful webservice which returns me a fairly complex json. I wish to pass it as-is to splunk and hope for splunk toparse it into key=value pairs.
What do i have to do? I can not seem to find a sample 😕
Surprisingly simple....
url="https://xxx/wapi/xxx"
values={'ip_address' : ipfield}
data = urllib.urlencode(values)
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, url, USERNAME, PASSWORD)
authhandler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(authhandler)
urllib2.install_opener(opener)
req = urllib2.Request(url, data)
pagehandle = urllib2.urlopen(req)
results=json.loads(pagehandle.read())
splunk.Intersplunk.outputResults( results )
Surprisingly simple....
url="https://xxx/wapi/xxx"
values={'ip_address' : ipfield}
data = urllib.urlencode(values)
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, url, USERNAME, PASSWORD)
authhandler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(authhandler)
urllib2.install_opener(opener)
req = urllib2.Request(url, data)
pagehandle = urllib2.urlopen(req)
results=json.loads(pagehandle.read())
splunk.Intersplunk.outputResults( results )