Skip to content

Commit

Permalink
Fix funny header in new version of requests, that prevented CKAN API …
Browse files Browse the repository at this point in the history
…calls(!). See #2942.
  • Loading branch information
David Read committed Sep 25, 2012
1 parent a15fd8d commit 05511a4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ckanext/qa/commands.py
Expand Up @@ -7,6 +7,8 @@

import logging

REQUESTS_HEADER = {'content-type': 'application/json'}

class CkanApiError(Exception):
pass

Expand Down Expand Up @@ -110,7 +112,7 @@ def _package_list(self):
for id in self.args[1:]:
data = json.dumps({'id': unicode(id)})
url = api_url + '/package_show'
response = requests.post(url, data)
response = requests.post(url, data, headers=REQUESTS_HEADER)
if not response.ok:
err = ('Failed to get package %s from url %r: %s' %
(id, url, response.error))
Expand All @@ -121,7 +123,8 @@ def _package_list(self):
page, limit = 1, 100
url = api_url + '/current_package_list_with_resources'
response = requests.post(url,
json.dumps({'page': page, 'limit': limit}))
json.dumps({'page': page, 'limit': limit}),
headers=REQUESTS_HEADER)
if not response.ok:
err = ('Failed to get package list with resources from url %r: %s' %
(url, response.error))
Expand All @@ -134,7 +137,8 @@ def _package_list(self):
yield p
url = api_url + '/current_package_list_with_resources'
response = requests.post(url,
json.dumps({'page': page, 'limit': limit}))
json.dumps({'page': page, 'limit': limit}),
headers=REQUESTS_HEADER)
if not response.ok:
err = ('Failed to get package list with resources from url %r: %s' %
(url, response.error))
Expand Down

0 comments on commit 05511a4

Please sign in to comment.