Hi I have been trying to import a dataset using ckan api call via python's urllib2 following the documentation at http://docs.ckan.org/en/latest/api/ the Code I am running is `
#!/usr/bin/env python
import urllib2
import urllib
import json
import pprint
dataset_dict = {
'name': 'my_dataset_name5',
'notes': 'A long description of my dataset',
}
data_string = urllib.quote(json.dumps(dataset_dict))
request = urllib2.Request(
'http://<ckan server ip>/api/action/package_create')
request.add_header('Authorization', 'my api key')
response = urllib2.urlopen(request, data_string)
assert response.code == 200
response_dict = json.loads(response.read())
assert response_dict['success'] is True
created_package = response_dict['result']
pprint.pprint(created_package)`
However it gives the following error:
Traceback (most recent call last):File "autodatv2.py", line 26, in response = urllib2.urlopen(request, data_string)File "/usr/lib64/python2.7/urllib2.py", line 154, in urlopen return opener.open(url, data, timeout)File "/usr/lib64/python2.7/urllib2.py", line 437, in open response = meth(req, response)File "/usr/lib64/python2.7/urllib2.py", line 550, in http_response 'http', request, response, code, msg, hdrs) File "/usr/lib64/python2.7/urllib2.py", line 475, in error return self._call_chain(*args) File "/usr/lib64/python2.7/urllib2.py", line 409, in _call_chain result = func(*args) File "/usr/lib64/python2.7/urllib2.py", line 558, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) urllib2.HTTPError: HTTP Error 409: Conflict
I am running CKAN version 2.4 with python 2.7.10 on a Amazon ec2 instance and echo $HTTP_PROXY shows nothing so I'm assuming it not a proxy issue.. Could someone please provide any help to resolve this issue