GSA / enterprise-data-inventory

The Enterprise Data Inventory is a CKAN based data management system for private and public data management
7 stars 5 forks source link

Accessing CKAN API methods at inventory.data.gov #187

Closed QJF3 closed 8 years ago

QJF3 commented 9 years ago

I am using httpie to test how to access inventory.data.gov. Any api methods with zero or more parameters generates a http error of 302 and redirects me to the inventory.data.gov/login. Not sure what I am doing wrong to use the APIs. My goals is to be able to update my organization's datasets in batch instead of through a manual process. Here's the log:

PS C:\Users\Dev> http -v GET https://inventory.data.gov/api/3/member_list id=userID Authorization:xxxxx-xx-xxx GET /api/3/member_list HTTP/1.1 Accept: application/json Accept-Encoding: gzip, deflate Authorization: xxxxx-xx-xxx Connection: keep-alive Content-Length: 21 Content-Type: application/json Host: inventory.data.gov User-Agent: HTTPie/0.9.2

{ "id": "userID" }

HTTP/1.1 302 Found Connection: Keep-Alive Content-Encoding: gzip Content-Length: 194 Content-Type: text/html; charset=iso-8859-1 Date: Mon, 05 Oct 2015 01:11:15 GMT Keep-Alive: timeout=15, max=100 Location: https://inventory.data.gov/user/login Server: Apache Vary: Accept-Encoding X-Frame-Options: SAMEORIGIN

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">

302 Found

Found

The document has moved here.

PS C:\Users\Dev>

hkdctol commented 9 years ago

@QJF3 which agency are you with? Do you already have an account and organization in inventory.data.gov?

QJF3 commented 9 years ago

I am with the VA and when I try to access the API I am using my authorization key that is issued to me as an Inventory.Data.Gov user.

ykhadilkar commented 9 years ago

@QJF3 Try below URL to get list of users. object_type can be changed to package or to get everything don't pass it. https://inventory.data.gov/api/action/member_list?id=va-gov&object_type=user

QJF3 commented 9 years ago

It works. Are you saying no user credentials, in the form of an authorization key are other key, are needed to read any content in inventory.data.gov?

ykhadilkar commented 9 years ago

In CKAN, for public organization “member_list” api method is public. http://docs.ckan.org/en/ckan-2.2/api.html#ckan.logic.action.get.member_list

However in inventory to get any specific package or user information, user will get redirected to login page. Other than member_list only data store related API's are public in inventory.

QJF3 commented 8 years ago

@ykhadilkar-rei How do I access private metadata in Inventory without being redirected to login page?

ykhadilkar commented 8 years ago

I suggesting using https://github.com/GSA/ckan-php-manager @alex-perfilov-reisys

vasili4 commented 8 years ago

@QJF3 with httpie, try this next time:

$ http -v GET "https://inventory.data.gov/api/3/action/package_show?id=XXX" Authorization:YYY Cookie:auth_tkt=foo

where:

QJF3 commented 8 years ago

Sorry its been so long since I was able to reply. Thanks for the suggestion @alex-perfilov-reisys, it worked.

For Inventory, I can't seem to access any content from organization va-gov, so I don't know to find the package_show?id=XXX through the API.

vasili4 commented 8 years ago

@QJF3 did you try package_search?q=organization:va-gov ?

QJF3 commented 8 years ago

Thanks @alex-perfilov-reisys. I am not returning all VA records, but some, so I can work it out from here. I am closing this issue.

vasili4 commented 8 years ago

@QJF3 , there is a hard limit of 1000 rows, so you will never get more than that per request. But you can use pagination, defining start and rows params, check docs for more http://docs.ckan.org/en/latest/api/#ckan.logic.action.get.package_search