[b]"How to Create a POST Request with Body Parameters in Flask?"[/b] or [b]"Flask: How to Properly Create a POST R

20 Replies, 614 Views

Hey everyone!

I'm trying to flask create post request with body parameters, but I'm kinda stuck. I’ve got this basic route set up, but when I send data, it’s not showing up like I expected.

Here’s what I’ve got:

```python
@app.route('/submit', methods=['POST'])
def submit():
data = request.json
return data
```

But when I test it with Postman or curl, sometimes the body just comes back empty. Am I missing something obvious?

Also, should I be using `request.form` or `request.get_json()` instead? I’ve seen mixed examples online, and it’s low-key confusing.

Any tips or working examples would be a lifesaver! Thanks in advance.

(PS: Using Flask 2.0 if that matters.)

Messages In This Thread
[b]"How to Create a POST Request with Body Parameters in Flask?"[/b] or [b]"Flask: How to Properly Create a POST R - by - 13-04-2024, 11:32 AM



Users browsing this thread: 1 Guest(s)