lus / pasty

pasty is a fast and lightweight code pasting server
https://pasty.lus.pm
MIT License
200 stars 27 forks source link

Return proper HTTP status for invalid content type #42

Open zevaryx opened 2 years ago

zevaryx commented 2 years ago

Making a request to /api/v2/pastes fails with invalid character 'x' looking for beginning of value.

Code to reproduce:

import requests
resp = requests.post("https://pasty.lus.pm/api/v2/pastes", data={"content": "Test paste"})

image

lus commented 2 years ago

I looked into the documentation of the requests.post method and it seems like the data parameter is being form encoded which is not supported by pasty (however, it shouldn't return a 500, this seems like an issue on my side that I have to fix). Please try to use the json parameter instead.

zevaryx commented 2 years ago

Yep, doing requests.post("...", json=...) solved it. Thanks for the quick feedback! I'll leave this open since there's some work needed with it