All Apps and Add-ons

REST API Modular Input: How can I make REST calls to MS Project Server 2013?

andrewtrobec
Motivator

Hello,

I am busy trying to configure the REST API Modular Input to make a REST call to my MS Project Server 2013 instance, but I'm not exactly sure how to configure the form and Custom Authentication Handler. I have a piece of Python code that authenticates me and makes a request to the URL that I want to retrieve data from:

import requests
from ntlm import HTTPNtlmAuthHandler
import getpass
import urllib2

SITE = "https://<MSPS_Server>/<Site>/"
USERNAME = "domain\\username"
PASSWORD = "<password>"

passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, SITE, USERNAME, PASSWORD)
auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman)
opener = urllib2.build_opener(auth_NTLM)
urllib2.install_opener(opener)

URL = "https://<MSPS_Server>/<Site>/_api/ProjectData/Resources?$select=ResourceId,ResourceName"
response = urllib2.urlopen(URL)
headers = response.info()
print("headers: {}".format(headers))
body = response.read()
print("response: " + body)

What I am having trouble with is figuring out how to modify the authhandlers.py file for authentication and what to put in the Endpoint URL field in the configuration form.

Any pointers would be greatly appreciated!

Thank you,

Andrew

jpvalenc
Path Finder

Were you able to figure it out?

0 Karma

jkat54
SplunkTrust
SplunkTrust

The rest api modular input is for calling Splunks api and putting data into splunk.

It's not for calling external apis.

However I have created a curl search command (shameless self promotion). It will allow you to post/get from external apis but it isn't perfect and is technically beta now. You'll find it in the jkats toolkit app on splunkbase.

To index the data into splunk you'd have to use the collect command after the curl command.

Looking at your script however, you may just want to use your script as a scripted input. Check out scripted inputs in the inputs.conf documentation for instructions on how to call your script as an input.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Best Practices: Splunk auto adjust pipeline queue

When you enable autoAdjustQueue in Splunk, maxSize should be understood as the queue size Splunk starts with ...

Request for Professional Development: Attending .conf26

Winning Over the Boss: Your Pass to .conf26 conf26 is going to be here before you know it. If don't already ...