pasty
pasty copied to clipboard
Return proper HTTP status for invalid content type
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"})
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.
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