有没有办法通过API调用访问私有数据集

问题描述 投票:1回答:1

我正在使用CKAN 2.8运行Mirth 3.6.1并成为新手我遇到了一个问题:有没有办法通过API请求访问CKAN中私有数据集中的资源?我似乎无法做到这一点。

我有一个拥有公共数据集的组织,我可以通过API路由器访问Mirth到正确的Mirth频道,并通过API请求从CKAN获取数据。但是,如果我将数据集设为私有,那么它就会崩溃。即使我使用正确的API密钥。虽然,这似乎没有什么区别。无论我是否使用API​​密钥(或者甚至是正确的密钥),我都会成功。

请求中包含的API密钥是sysadmin的API密钥。

当我通过CKAN端点直接访问CKAN资源并且数据集是公共的时,我收到此响应:

{
    "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)
            }
        ]
    }
}

当数据集是私有的时,无论我是否包含API密钥(或者它是否是真正的api-key),我都会得到以下响应:

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

那么,如何为私有数据集中的资源执行resource_search?

提前致谢。

api backend ckan mirth
1个回答
2
投票

是的,您可以通过在数据集中使用include_private:True来实现

请参阅以下链接https://docs.ckan.org/en/2.8/api/index.html#ckan.logic.action.get.package_search

© www.soinside.com 2019 - 2024. All rights reserved.