- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
08-26-2026 09:39 AM - edited 08-26-2026 09:40 AM
Hello everyone,
We are currently considering to us a HTTP Log Collector.
However, before this can be started, I wanted to test the collection.
Now, in theory, this should not be hard, due to the examples provided after setting up the integration.
Nonetheless, either the Python Example is faulty in some way, or I am being exceedingly stupid.
Currently, my code looks like this, very close to the provided example:
def test_http_collector(api_key: str) -> requests.Response:
headers = {
"Authorization": api_key,
"Content-Type": "text/plain"
}
# Note: the logs must be separated by a new line
body = "{'example1': 'test', 'timestamp': 1609100113039}\n{'example2': [12321,546456,45687,1]}"
res = requests.post(url="https://api-<name>.xdr.de.paloaltonetworks.com/logs/v1/event",
headers=headers,
data=body,
timeout=600
)
return res
I've only added a timeout and changed the linebreak (which would not add a newline) to a \n.
This consistently seems to return HTTP 500 for me.
The best I've managed in trying multiple ways for hours is HTTP 400 and I cannot even replicate it right now.
Does someone who is running a working HTTP log collector have any idea?
Or maybe a tested and proven, minimal working example?
Is there anywhere I can check what actually happened in XSIAM?
08-26-2026 03:54 PM - edited 08-26-2026 03:55 PM
Hi there,
I tested the example in the documentation, and I could not get it to work until I fixed the single/double quotes.
Please test by replacing them as such:
body = '{"example": "test", "timestamp": 1609100113039}\n{"example2": [12321,546456,45687,1]}'
Let me know if this helps.
BR
Raúl
08-27-2026 06:13 AM
A bit of testing has turned out a few more things, and likely the cause of the specific HTTP 400:
While Raúl was correct about the quotes being an issue with Python, the HTTP 400 error seems to arise whenever a HTTP collector instance is changed - e.g. the input type is changed from RAW to JSON, or the compression is changed from Gzip to uncompressed or ...
As this has cost me a lot of nerves and testing, here are some of my findings
Working Python example function:
def test_http_collector(api_key: str, collector_url: str) -> requests.Response:
headers = {"Authorization": api_key, "Content-Type": "application/json"}
# Note: the logs must be separated by a new line
msg_1 = '{"msg": "This is my test!", "severity": "High", "id": "EJhn90nsdui2", "duration": 432, "timestamp": 1609100113039}'
msg_2 = '{"msg": "I am also a test", "severity": "Low", "id": "kdrjhWo834jhz", "duration": 20, "timestamp": 1609100113052}'
body = f"{msg_1}\n{msg_2}"
return requests.post(
url=collector_url,
headers=headers,
data=body,
timeout=600
)
08-26-2026 03:54 PM - edited 08-26-2026 03:55 PM
Hi there,
I tested the example in the documentation, and I could not get it to work until I fixed the single/double quotes.
Please test by replacing them as such:
body = '{"example": "test", "timestamp": 1609100113039}\n{"example2": [12321,546456,45687,1]}'
Let me know if this helps.
BR
Raúl
08-26-2026 11:28 PM
Thank you!
This is what I must have done once, because it at least produces a 400 - Bad Request.
Which is further then I got, but I still do not know why this is happening.
08-27-2026 06:13 AM
A bit of testing has turned out a few more things, and likely the cause of the specific HTTP 400:
While Raúl was correct about the quotes being an issue with Python, the HTTP 400 error seems to arise whenever a HTTP collector instance is changed - e.g. the input type is changed from RAW to JSON, or the compression is changed from Gzip to uncompressed or ...
As this has cost me a lot of nerves and testing, here are some of my findings
Working Python example function:
def test_http_collector(api_key: str, collector_url: str) -> requests.Response:
headers = {"Authorization": api_key, "Content-Type": "application/json"}
# Note: the logs must be separated by a new line
msg_1 = '{"msg": "This is my test!", "severity": "High", "id": "EJhn90nsdui2", "duration": 432, "timestamp": 1609100113039}'
msg_2 = '{"msg": "I am also a test", "severity": "Low", "id": "kdrjhWo834jhz", "duration": 20, "timestamp": 1609100113052}'
body = f"{msg_1}\n{msg_2}"
return requests.post(
url=collector_url,
headers=headers,
data=body,
timeout=600
)
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!

