Kaa REST api呼叫" 404未找到"

时间:2016-11-22 16:11:09

标签: kaa

我正在使用Kaa下载页面提供的AMI在AWS上部署Kaa sandbox v0.10.0。

我正在尝试这里描述的一些示例调用:http://docs.kaaproject.org/display/KAA/Admin+REST+API并且我总是在应用程序ID或应用程序令牌上遇到GET请求错误。

我可以通过此请求获取令牌和ID:

curl -v -S -u devuser:devuser123 -X GET "http://my-sandbox:8080/kaaAdmin/rest/api/applications" | python -mjson.tool

回应(好):

* Hostname was NOT found in DNS cache   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed   0     0    0     0    0     0      0      0 --:--:-- --:--:--
--:--:--     0*   Trying ***.***.***.***...
* Connected to my-sandbox (***.***.***.***) port 8080 (#0)
* Server auth using Basic with user 'devuser'
> GET /kaaAdmin/rest/api/applications HTTP/1.1
> Authorization: Basic ZGV2dXNlcjpkZXZ1c2VyMTIz
> User-Agent: curl/7.35.0
> Host: my-sandbox:8080
> Accept: */*
>  < HTTP/1.1 200 OK < Date: Tue, 22 Nov 2016 15:27:06 GMT < Set-Cookie: JSESSIONID=cm5f9odz7iucto5kns8o8qmd;Path=/ < Expires: Thu, 01 Jan 1970 00:00:00 GMT < Content-Type: application/json;charset=UTF-8 < Transfer-Encoding: chunked
* Server Jetty(9.2.2.v20140723) is not blacklisted < Server: Jetty(9.2.2.v20140723) <  { [data not shown] 100  3147    0  3147    0 0   4542      0 --:--:-- --:--:-- --:--:--  4541
* Connection #0 to host my-sandbox left intact [
    {
        "applicationToken": "25594577458910686729",
        "credentialsServiceName": "Trustful",
        "id": "1",
        "name": "Endpoint profiles and grouping demo",
        "sequenceNumber": 10,
        "tenantId": "1"
    },
    {
        "applicationToken": "73690609119489701916",
        "credentialsServiceName": "Trustful",
        "id": "2",
        "name": "Configuration demo",
        "sequenceNumber": 3,
        "tenantId": "1"
    },
    {
        "applicationToken": "59655266968010281243",
        "credentialsServiceName": "Trustful",
        "id": "3",
        "name": "Notification demo",
        "sequenceNumber": 3,
        "tenantId": "1"
    },
    {
        "applicationToken": "74360883947464962688",
        "credentialsServiceName": "Internal",
        "id": "4",
        "name": "Credentials demo",
        "sequenceNumber": 1,
        "tenantId": "1"
    },
    {
        "applicationToken": "09804246192781707713",
        "credentialsServiceName": "Trustful",
        "id": "5",
        "name": "Data collection demo",
        "sequenceNumber": 2,
        "tenantId": "1"
    },
    {
        "applicationToken": "48703828557071439020",
        "credentialsServiceName": "Trustful",
        "id": "6",
        "name": "Event demo",
        "sequenceNumber": 1,
        "tenantId": "1"
    },
    {
        "applicationToken": "23961666823127162504",
        "credentialsServiceName": "Trustful",
        "id": "7",
        "name": "User verifiers demo",
        "sequenceNumber": 3,
        "tenantId": "1"
    },
    {
        "applicationToken": "24510582477967418632",
        "credentialsServiceName": "Trustful",
        "id": "8",
        "name": "Zeppelin data analytics demo",
        "sequenceNumber": 1,
        "tenantId": "1"
    },
    {
        "applicationToken": "69723522420999062824",
        "credentialsServiceName": "Trustful",
        "id": "9",
        "name": "Storm data analytics demo",
        "sequenceNumber": 1,
        "tenantId": "1"
    },
    {
        "applicationToken": "68275681743382249643",
        "credentialsServiceName": "Trustful",
        "id": "10",
        "name": "Cassandra data analytics demo",
        "sequenceNumber": 1,
        "tenantId": "1"
    },
    {
        "applicationToken": "49633755999810794988",
        "credentialsServiceName": "Trustful",
        "id": "11",
        "name": "Spark data analytics demo",
        "sequenceNumber": 1,
        "tenantId": "1"
    },
    {
        "applicationToken": "25016131899946649961",
        "credentialsServiceName": "Trustful",
        "id": "12",
        "name": "GPIO control master",
        "sequenceNumber": 1,
        "tenantId": "1"
    },
    {
        "applicationToken": "41988108505666436316",
        "credentialsServiceName": "Trustful",
        "id": "13",
        "name": "GPIO control slave",
        "sequenceNumber": 1,
        "tenantId": "1"
    },
    {
        "applicationToken": "85870645700025909809",
        "credentialsServiceName": "Trustful",
        "id": "14",
        "name": "Cell monitor",
        "sequenceNumber": 1,
        "tenantId": "1"
    },
    {
        "applicationToken": "47750979047259772609",
        "credentialsServiceName": "Trustful",
        "id": "15",
        "name": "City guide",
        "sequenceNumber": 7,
        "tenantId": "1"
    },
    {
        "applicationToken": "83795629594970241248",
        "credentialsServiceName": "Trustful",
        "id": "16",
        "name": "Photo frame",
        "sequenceNumber": 1,
        "tenantId": "1"
    },
    {
        "applicationToken": "48284436316351850395",
        "credentialsServiceName": "Trustful",
        "id": "32768",
        "name": "Application 1 v2",
        "sequenceNumber": 0,
        "tenantId": "1"
    } ]

但是当我尝试通过其令牌获取应用程序时,它不起作用。

请求:

curl -v -S -u devuser:devuser123 -X GET "http://my-sandbox:8080/kaaAdmin/rest/api/application/token/25594577458910686729" | python -mjson.tool

回应(错误):

** Hostname was NOT found in DNS cache
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying ***.***.***.***...
* Connected to my-sandbox (***.***.***.***) port 8080 (#0)
* Server auth using Basic with user 'devuser'
> GET /kaaAdmin/rest/api/application/token/25594577458910686729 HTTP/1.1
> Authorization: Basic ZGV2dXNlcjpkZXZ1c2VyMTIz
> User-Agent: curl/7.35.0
> Host: my-sandbox:8080
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< Date: Tue, 22 Nov 2016 15:28:40 GMT
< Set-Cookie: JSESSIONID=1rb4gm0qf42jf2sjfi4dikqu6;Path=/
< Content-Type: text/html; charset=ISO-8859-1
< Cache-Control: must-revalidate,no-cache,no-store
< Content-Length: 340
* Server Jetty(9.2.2.v20140723) is not blacklisted
< Server: Jetty(9.2.2.v20140723)
< 
{ [data not shown]
100   340  100   340    0     0   1840      0 --:--:-- --:--:-- --:--:--  1847
* Connection #0 to host my-sandbox left intact
No JSON object could be decoded*

具有相同错误的类似请求(404):

curl -v -S -u devuser:devuser123 -X GET "http://my-sandbox:8080/kaaAdmin/rest/api/application/1" | python -mjson.tool

curl -v -S -u devuser:devuser123 -X GET "http://my-sandbox:8080/kaaAdmin/rest/api/serverProfileSchemasByAppToken/48703828557071439020" | python -mjson.tool

curl -v -S -u devuser:devuser123 -X GET "http://my-sandbox:8080/kaaAdmin/rest/api/profileSchemasByAppToken/48703828557071439020" | python -mjson.tool

非常感谢任何帮助!

1 个答案:

答案 0 :(得分:1)

似乎您已在0.9版文档(http://docs.kaaproject.org/display/KAA/Kaa+IoT+Platform+Home)中阅读过有关此REST调用的内容。但是你使用的是Kaa 0.10。

在0.9中,不推荐使用id获取应用程序,但是在0.10中它已被删除并且

/kaaAdmin/rest/api/application/token/${app_token}

替换为

/kaaAdmin/rest/api/application/${app_token}.

所以,它应该可以正常工作:

curl -v -S -u devuser:devuser123 -X GET "http://my-sandbox:8080/kaaAdmin/rest/api/application/25594577458910686729" | python -mjson.tool

在最新版本http://kaaproject.github.io/kaa/docs/latest的文档中阅读更多内容。