Sentry: APIError(No JSON data was found)

Created on 16 Jan 2018  路  2Comments  路  Source: getsentry/sentry

I installed raven==6.1.0 and tried sending a test event by running

python manage.py raven test -v 3

but get this:
Sentry responded with an API error: APIError(No JSON data was found)

then I tried api with the follow sentences:
`import requests

url = "http://sentry.pf.xiaomi.com/api/6/store/"

payload = {
"event_id": "fc6d8c0c43fc4630ad850ee518f1b9d0",
"culprit": "my.module.function_name",
"timestamp": "2011-05-02T17:41:36",
"message": "SyntaxError: Wattttt!",
"exception": [{
"type": "SyntaxError",
"value": "manual_test_api_by_wu",
"module": "__builtins__"
}]
}
headers = {
'content-type': "application/json",
'user-agent': "raven-python/1.0",
'x-sentry-auth': "Sentry sentry_timestamp=1515478873.2674391, sentry_client=raven-python/6.1.0, sentry_version=6, sentry_key=key, sentry_secret=secret",
'cache-control': "no-cache"
}

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)`

and get the same error

my Sentry server version is 8.16.0 (now is 8.17.0 and the error occurs as usual)

Most helpful comment

While I'm very late on this. I'm leaving this for future visitors.

I was having the same problem, and the reason was that the HTTP requests were being redirected to HTTPS before they reached Sentry, and if you redirect a POST request, the body is lost, which causes this error.

All 2 comments

We document the API here pretty heavily: https://docs.sentry.io/clientdev/

But it looks like there's something wrong on your setup, maybe something stripping the POST body since the python manage.py raven test yielded the same error.

While I'm very late on this. I'm leaving this for future visitors.

I was having the same problem, and the reason was that the HTTP requests were being redirected to HTTPS before they reached Sentry, and if you redirect a POST request, the body is lost, which causes this error.

Was this page helpful?
0 / 5 - 0 ratings