[ckan-dev] Getting resources from packages via the ckanapi

Koebrick, Andrew (MNIT) andrew.koebrick at state.mn.us
Thu Feb 23 18:44:26 UTC 2017


Hoping somebody can assist:  I am attempting to create a report for one of my ckan instances that lists all the organizations, and then all of their packages along with the id of the packages' resource (we have only one resource per package).  However, I do not seem to be able to link to the resource id via API calls.

Here is what I have so far:

organizations = ckan.action.organization_list(include_datasets ='True')
for organization in organizations:

         packages= orgDetails['packages']

         for package in packages:

                 #And here is where it breaks down.... Here are a few of the many searches / shows I have tried:

                 resourceObj = ckan.action.resource_search(query='package_id:' +package['id'])

                    #which returns: {u'query': u'Field "package_id" not recognised in resource_search.', u'__type': u'Validation Error'}

                 revisionObj = ckan.action.revision_show(id=package['revision_id'])

                    #which just brings back information already knows about the revision.





While iterating through the package information I seem unable to get the related resources.  I have tried all sorts of queries using what info I have from the package to get the related resources.



What can I use to link from the package list found in the return object from organization_show to get resources?



Many thanks,

Andrew Koebrick  |  MINNESOTA GEOSPATIAL INFORMATION OFFICE
Web Coordinator / Systems administrator / Librarian
MN.IT Services @ MNGEO
651-201-2465 (w)  |   651-296-6398 (f) |  andrew.koebrick at state.mn.us<mailto:andrew.koebrick at state.mn.us>
658 Cedar St., Room 300, St. Paul, MN 55155, www.mngeo.state.mn.us<http://www.mngeo.state.mn.us/>

[cid:image002.jpg at 01CE61F8.52552AE0]<http://www.mn.gov/oet>

Information Technology for Minnesota Government   |   mn.gov/mnit<http://www.mn.gov/oet>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20170223/ac4c135e/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 1624 bytes
Desc: image001.jpg
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20170223/ac4c135e/attachment-0002.jpg>


More information about the ckan-dev mailing list