0
votes

I am working on the Kaa sandbox v0.10.0 deployed on AWS using the AMI provided by the Kaa download page.

I am trying some of the sample calls described here : http://docs.kaaproject.org/display/KAA/Admin+REST+API and I always get an error with GET requests on application id or application token.

I can get the tokens and IDs with this request :

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

response (OK) :

* 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"
    } ]

But when I try to get an application by its token, it does not work.

request :

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

response (ERROR) :

** 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*

Similar requests with same error (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

Any help would be much appreciated!

1

1 Answers

1
votes

Seems you've read about this REST call's in documentation for version 0.9 (http://docs.kaaproject.org/display/KAA/Kaa+IoT+Platform+Home). But you are using Kaa 0.10.

In 0.9 getting application by id is deprecated, but in 0.10 it's removed and

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

is replaced by

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

So, it should work ok:

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

Read more in docs for latest version http://kaaproject.github.io/kaa/docs/latest.