pasty icon indicating copy to clipboard operation
pasty copied to clipboard

Return proper HTTP status for invalid content type

Open zevaryx opened this issue 2 years ago • 2 comments

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

zevaryx avatar Feb 22 '22 19:02 zevaryx

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.

lus avatar Feb 22 '22 20:02 lus

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

zevaryx avatar Feb 22 '22 22:02 zevaryx