Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird Error On Resource Upload #22

Closed
saulshanabrook opened this issue Jun 18, 2014 · 1 comment
Closed

Weird Error On Resource Upload #22

saulshanabrook opened this issue Jun 18, 2014 · 1 comment

Comments

@saulshanabrook
Copy link
Contributor

import StringIO
import ckanapi
import json
import os

CKAN_URL = 'http://www.opendatadc.org'
CKAN_API_KEY = os.environ['CKAN_API_KEY']

ckan = ckanapi.RemoteCKAN(
    CKAN_URL,
    apikey=CKAN_API_KEY,
)
payload = {'description': 'Scraped from http://geospatial.dcgis.dc.gov/ocf/getData.aspx',
 'format': 'json',
 'id': u'808ebae5-d23c-451f-970e-a657b3d3d540',
 'mimetype': 'application/json',
 'name': 'Committees Running Per Year',
 'package_id': 'campaign-finance',
 'upload': StringIO.StringIO('["dfd", "dfd"]'),
 'url': 'http://www.opendatadc.orgdatset/campaign-finance/resource/808ebae5-d23c-451f-970e-a657b3d3d540'}

ckan.action.resource_update(**payload)

Gives me a weird exception

CKANAPIError                              Traceback (most recent call last)
<ipython-input-4-0261da11b7f6> in <module>()
     19  'url': 'http://www.opendatadc.orgdatset/campaign-finance/resource/808ebae5-d23c-451f-970e-a657b3d3d540'}
     20
---> 21 ckan.action.resource_update(**payload)

/Users/saul/.virtualenvs/tempenv-28c0218950914/lib/python2.7/site-packages/ckanapi/common.pyc in action(**kwargs)
     47                 return self._ckan.call_action(name,
     48                     data_dict=nonfiles,
---> 49                     files=files)
     50             return self._ckan.call_action(name, data_dict=kwargs)
     51         return action

/Users/saul/.virtualenvs/tempenv-28c0218950914/lib/python2.7/site-packages/ckanapi/remoteckan.pyc in call_action(self, action, data_dict, context, apikey, files)
     80         else:
     81             status, response = self._request_fn(url, data, headers, files)
---> 82         return reverse_apicontroller_action(url, status, response)
     83
     84     def _request_fn(self, url, data, headers, files):

/Users/saul/.virtualenvs/tempenv-28c0218950914/lib/python2.7/site-packages/ckanapi/common.pyc in reverse_apicontroller_action(url, status, response)
    104
    105     # don't recognize the error
--> 106     raise CKANAPIError(repr([url, status, response]))

CKANAPIError: ['http://www.opendatadc.org/api/action/resource_update', 400, u'"Bad request - JSON Error: Error decoding JSON data. Error: JSONDecodeError(\'Expecting value: line 1 column 2 (char 1)\',) JSON data extracted from the request: \'--11da1b66348f4c54b15ed923a219bd17;\\\\r\\\\nContent-Disposition: form-data; name=\\"mimetype\\"\\\\r\\\\n\\\\r\\\\napplication/json\\\\r\\\\n--11da1b66348f4c54b15ed923a219bd17;\\\\r\\\\nContent-Disposition: form-data; name=\\"description\\"\\\\r\\\\n\\\\r\\\\nScraped from http://geospatial.dcgis.dc.gov/ocf/getData.aspx\\\\r\\\\n--11da1b66348f4c54b15ed923a219bd17;\\\\r\\\\nContent-Disposition: form-data; name=\\"format\\"\\\\r\\\\n\\\\r\\\\njson\\\\r\\\\n--11da1b66348f4c54b15ed923a219bd17;\\\\r\\\\nContent-Disposition: form-data; name=\\"url\\"\\\\r\\\\n\\\\r\\\\nhttp://www.opendatadc.orgdatset/campaign-finance/resource/808ebae5-d23c-451f-970e-a657b3d3d540\\\\r\\\\n--11da1b66348f4c54b15ed923a219bd17;\\\\r\\\\nContent-Disposition: form-data; name=\\"package_id\\"\\\\r\\\\n\\\\r\\\\ncampaign-finance\\\\r\\\\n--11da1b66348f4c54b15ed923a219bd17;\\\\r\\\\nContent-Disposition: form-data; name=\\"id\\"\\\\r\\\\n\\\\r\\\\n808ebae5-d23c-451f-970e-a657b3d3d540\\\\r\\\\n--11da1b66348f4c54b15ed923a219bd17;\\\\r\\\\nContent-Disposition: form-data; name=\\"name\\"\\\\r\\\\n\\\\r\\\\nCommittees Running Per Year\\\\r\\\\n--11da1b66348f4c54b15ed923a219bd17;\\\\r\\\\nContent-Disposition: form-data; name=\\"upload\\"; filename=\\"upload\\"\\\\r\\\\nContent-type: text/plain\\\\r\\\\n\\\\r\\\\n[\\"dfd\\", \\"dfd\\"]\\\\r\\\\n--11da1b66348f4c54b15ed923a219bd17;--\'"']
@saulshanabrook
Copy link
Contributor Author

Never mind, this was on a CKAN 2.0 instance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant