Is there any way to access private datasets through API call

亡梦爱人 提交于 2020-01-03 03:40:10

问题


I'm running Mirth 3.6.1 with CKAN 2.8 and being a newbie to this I've run into an issue: Is there a way to access resources in private datasets in CKAN through API requests? I can't seem to do it.

I have an organization with a public dataset and I can can go through Mirth via the API router to the correct Mirth channel and get the data from CKAN, like normal, with an API request. But if I make the dataset private, it all falls apart. Even though I use the correct API-key. Although, that doesn't seem to make a difference. I get success true regardless of whether I use the API-key or not (or if it's even the correct key)

The API-key included in the request is that of the sysadmin.

When I directly access the CKAN resource through a CKAN-endpoint and the dataset is public, I get this response:

{
    "help": "https://URL/api/3/action/help_show?name=resource_search", (URL instead of real url)
    "success": true,
    "result": {
        "count": 1,
        "results": [
            {
                "mimetype": null,
                "cache_url": null,
                "state": "active",
                "hash": "REDACTED__", (sensitive data)
                "description": "",
                "format": "",
                "url": "https://URL/datastore/dump/0696c0a1-b249-4fd5-ba80-caf7046a650b", (URL instead of real url)
                "datastore_active": true,
                "created": "2019-03-19T00:30:04.313593",
                "cache_last_updated": null,
                "package_id": "11211598-34f8-4d67-ab34-b7fd590ae08d",
                "mimetype_inner": null,
                "last_modified": null,
                "position": 1,
                "revision_id": "17b85d36-4ec1-4645-b9b1-dcfe310a54e6",
                "size": null,
                "url_type": "datastore",
                "id": "0696c0a1-b249-4fd5-ba80-caf7046a650b",
                "resource_type": null,
                "name": "REDACTED" (sensitive data)
            }
        ]
    }
}

When the dataset is private, regardless of whether I include the API-key or not (or if it's even the real api-key), I get this response:

{
    "help": "https://URL/api/3/action/help_show?name=resource_search",
    "success": true,
    "result": {
        "count": 0,
        "results": []
    }
}

So, how can I do a resource_search for a resource in a private dataset?

Thanks in advance.


回答1:


Yes you can do that by using include_private:True in the dataset

Please see the below link https://docs.ckan.org/en/2.8/api/index.html#ckan.logic.action.get.package_search



来源:https://stackoverflow.com/questions/55245295/is-there-any-way-to-access-private-datasets-through-api-call

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!