#3248 Fix accessing data in API methods if sent as JSON
Merged by pingou. Opened by bkabrda.
bkabrda/pagure api-request-json  into  master

Download 3248.patch

flask.request.form is filled with data only if Content-Type header is set to application/x-www-form-urlencoded (or a similar value indicating a form). However, if a client sends Content-Type: application/json, flask.request.form is empty and we need to access flask.request.get_json() to obtain the data.

FTR I'm still running tests to see if I didn't break anything. I'll update this issue once the tests finish.

rebased onto 496020f3adeabafbf72329eea46b2934268be402

I did one more minor fix after which all tests seem to pass. This should be ok to merge from my side.

No tests?

I can add some tests later today.

rebased onto 727932116aeda276a5d75e58b8c17cfd509cb12e

I added a test that makes sure the get_request_data function works correctly. I don't see a good way to make sure all the API endpoints that access the data are tested (especially since this is dependent on their implementation and that can change over time).

Let's give it a try :)

Pull-Request has been merged by pingou

Metadata