I’m trying to post a message to my Graylog server over the RestAPI via a Python script I wrote for one of my Linux servers, and I’m getting HTTP errors (everything from 400, 404 to 415, etc). I’ve tried auth by username/password, auth by token, and I’ve tried structuring the JSON in different forms. I’m sure I’m missing something really stupid, but after a lot of Googling and trying different permutations, here I am.
I would like to state I’m not good at Python scripting yet, I just get by . Some greater details on your environment would be appreciated. The only thing I can do for you is give some suggestion about your network.
As for these errors, I’m quite sure you know what they mean but for an over all view it helps to understand what going on in your network.
400 Bad Request
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.
404 Not Found
The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable.
415 Unsupported Media Type
The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.
NOTE: If your trying to use the API from a remote device to your graylog server it would be best that all devices have a static IP Address other then a loop back address. This way you’ll miss a lot of issues in the future. Making sure the correct network ports are opened and not being blocked. A good way is to execute a TCPDUMP on graylog. For example here are a couple commands I personally like to use.