Closed adborden closed 4 days ago
As a workaround, you should url encode your json data and specify Content-Type: application/x-www-form-urlencoded
import json
import urllib.parse
import requests
encoded_data = urllib.parse.quote(json.dumps(data_dict))
response = requests.post(url, data=encoded_data, headers={'Content-Type': 'application/x-www-form-urlencoded'})
Found this commit which also works around the issue for datapusher https://github.com/GSA/datagov-deploy/commit/1c3be95f88afc52a102f6d92df1e20f4678b425b
Not a bug we will fix. Closing.
This looks like a bug in CKAN. When application/json is specified, it returns 400 and the message:
Specifying application/x-www-form-urlencoded seems to keep it happy, even though it's parsing json.
I've only seen this with POST methods.
How to reproduce
package_create.json
:Expected behavior
200
Actual behavior
400