Comments (3)
And, when this error occurs, I'd love to see the POST body!
from drf-api-logger.
You probably get the same response from API as well. As we can see from the screenshot you shared, the response is not JSON.
You are using POST call with no JSON data (body). Use empty JSON {} and the call POST API.
The DRF API Logger is only for JSON-type data.
Use the postman client app to call the API and then compare the response from the DRF API Logger Admin panel.
If you want to log extra information that DRF API Logger cannot log, use signals and log the data manually.
How to use signals and how to log data in the DRF API Logger model? Check the README.md for more information.
from drf-api-logger.
The response is proper JSON. It's the request that has invalid JSON. I am not calling with an empty body. It has a body that is invalid JSON. Below is more info about an example.
Request 2 below is a POST request to DRF, and has a non-empty POST body that is not logged by DRF API Logger. Perhaps you're saying this library only logs valid JSON POST bodies. I'm saying that it would be helpful if it logged the POST body even if it is invalid JSON. In fact, that's very helpful because that's a case where I really want to see the body!
I would re-open this issue if I could. I'll read the README about how to try to use signals to log the body, but I would appreciate any help.
===========================
- Sending a request that works, using httpie:
$ cat ok.json
{ "question": "?", "creator": "example", "name": "example name" }
$ cat ok.json | http POST http://localhost:8000/api/v1/polls/
HTTP/1.1 201 Created
...
{
"category": "",
"created_dt": "2021-03-05T14:37:02.627205Z",
"creator": "example",
"id": "ABR5OZIwAhQ",
"name": "example name",
"question": "?"
}
- Sending a request with a POST body that is invalid JSON (extra double quote):
$ cat not_ok.json
{ "question": "?", "creator": "example"", "name": "example name" }
$ cat not_ok.json | http POST http://localhost:8000/api/v1/polls/
HTTP/1.1 400 Bad Request
...
{
"detail": "JSON parse error - Expecting ',' delimiter: line 1 column 40 (char 39)"
}
It had a POST body, but that body was not logged:
from drf-api-logger.
Related Issues (20)
- 500 not logged HOT 2
- User Details to Logs HOT 4
- Maximum request and response body size HOT 2
- DRF-API-Logger empty log HOT 1
- The "Number of API calls" table does not work with LANGUAGE_CODE='ru'
- Remove old logs HOT 5
- Guidance on how to test this HOT 1
- Cant open the website after installing this package HOT 2
- It doesn't work properly. HOT 1
- Admin page is broken after installation HOT 3
- Function mask_sensitive_data doesn't cover list of dicts HOT 2
- Will this work with GraphQL? HOT 2
- Logger did not log any data for some endpoint on database
- Storing Tracing ID in Database
- storing user, view, view method, HOT 1
- Add History Table to increase performance of the view HOT 1
- Can not find static files as soon as I use this package HOT 5
- Additional information saved as part of "API Logs" model HOT 1
- SyntaxWarning on line 63 of utils.py in Python 3.12 HOT 1
- Package name in setup.py should be the same as your pip install `drf-api-logger`.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from drf-api-logger.