1

When I'm doing a GET request everything works fine but when I try a POST request, it returns 404.

I'm working on this API that interacts with Nagios : https://github.com/EyesOfNetworkCommunity/eonapi

Here's my python GET resquest :

import requests

r = requests.get('https://device/eonapi/getAuthenticationStatus?username=test&apiKey=49fd4f56qs4dfs2sdf4')

print(r.json())
print(r.status_code)

And the result :

{'api_version': '2.4.2', 'http_code': '200 OK', 'status': 'authorized'}
200

The POST request when I'm trying to get information about a monitored host :

import requests

r = requests.post('https://device/eonapi/getHost?username=test&apiKey=49fd4f56qs4dfs2sdf4', data = {'hostName':'test1'})

print(r.status_code)

Result :

404

I don't know what I'm doing wrong, I tried these requests with PHP and cURL but I still get the same results.

  • Use `'Content-Type': "application/json"` in the headers and use double quotes for your JSON data. See https://stackoverflow.com/a/36038497/12409170 – Rickard Körkkö Jan 21 '20 at 09:40
  • I tried but unfortunately still get 404 `import requests host = { "hostName":"test1" } headers = {'Content-type': 'application/json'} r = requests.post('https://device/eonapi/getHost?username=test&apiKey=49fd4f56qs4dfs2sdf4', data=host, headers=headers) print(r.status_code) ` – backupadm1n Jan 21 '20 at 10:24

1 Answers1

-2

You probably have to use a get request because the url says "getHost" and your trying to get data. Have you tried using get on that url?

Nite Block
  • 228
  • 1
  • 3
  • The documentation of eonapi states, that this must be a post request. – Felix Kleine Bösing Jan 21 '20 at 09:18
  • Well yes I'm trying to get the name of the host but it requires a POST request. You post the hostname and you get information. It is written in the documentation. Although I did try with GET and I still got 404 – backupadm1n Jan 21 '20 at 09:22