drewkerrigan/nagios-http-json

Include API Method

Closed this issue · 2 comments

Hi,
right now the script uses only the Method GET. We have now some API-Calls which requires instead of GET a POST Method.
In our case no further parameters are needed. The return data is in json format an contains only "value: 12345".
Would be great to add a parameter where it can be switched between GET and POST.
Thx

I have added the method "POST" by a "quick and dirty" fix into the python script by adding this lines:

Line 445:
parser.add_argument('-M', '--method', dest='method', help='HTTP Method to use', Default Method is GET, POST can be defined)

Line 585:
if args.method != 'POST' :
args.method = 'GET'

Line 590:
req = urllib.request.Request(url, method=args.method)

Anyhow I recommend, to review the whole python Code and "optimize" it

Hi, can you test this? #79