FIWARE Orion Context Broker API V2 - аккумулятор-server.py - PullRequest
0 голосов
/ 24 мая 2018

Когда я пытаюсь создать подписку, используя следующий запрос:

curl -v localhost:1026/v2/subscriptions -s -S --header 'Content-Type: application/json' -d @- <<EOF
{
   "description": "A subscription to get info about Room1",
   "subject": {
     "entities": [
       {
         "id": "Room10",
         "type": "Room"
       }
     ],
     "condition": {
       "attrs": ["pressure"]
     }
   },
   "notification": {
     "http": {
       "url": "http://localhost:1028/publish"
     },
     "attrs": ["temperature"]
   },
   "expires": "2040-01-01T14:00:00.00Z",
   "throttling": 5
}
EOF

Возникает ошибка:

* About to connect() to localhost port 1026 (#0)
*   Trying ::1... connected
* Connected to localhost (::1) port 1026 (#0)
> POST /v2/subscriptions HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.16.2.3 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: localhost:1026
> Accept: */*
> Content-Type: application/json
> Content-Length: 376
> 
< HTTP/1.1 400 Bad Request
< Connection: Keep-Alive
< Content-Length: 72
< Content-Type: application/json
< Date: Thu, 24 May 2018 07:38:32 GMT
< 
* Connection #0 to host localhost left intact
* Closing connection #0
{"error":"BadRequest","description":"no condition attributes specified"}

Однако, если я делаю запрос, используя V1 APIвсе работает правильно.Я не знаю почему.Пожалуйста, помогите мне!

1 Ответ

0 голосов
/ 25 мая 2018

Я протестировал ваш тот же запрос с последней версией Orion (1.13.0 + некоторые еще не выпущенные вещи только в основной ветке в настоящий момент), и он работает:

$ curl -v localhost:1026/v2/subscriptions -s -S --header 'Content-Type: application/json' -d @- <<EOF
> {
>    "description": "A subscription to get info about Room1",
>    "subject": {
>      "entities": [
>        {
>          "id": "Room10",
>          "type": "Room"
>        }
>      ],
>      "condition": {
>        "attrs": ["pressure"]
>      }
>    },
>    "notification": {
>      "http": {
>        "url": "http://localhost:1028/publish"
>      },
>      "attrs": ["temperature"]
>    },
>    "expires": "2040-01-01T14:00:00.00Z",
>    "throttling": 5
> }
> EOF
* Hostname was NOT found in DNS cache
*   Trying ::1...
* Connected to localhost (::1) port 1026 (#0)
> POST /v2/subscriptions HTTP/1.1
> User-Agent: curl/7.38.0
> Host: localhost:1026
> Accept: */*
> Content-Type: application/json
> Content-Length: 400
> 
* upload completely sent off: 400 out of 400 bytes
< HTTP/1.1 201 Created
< Connection: Keep-Alive
< Content-Length: 0
< Location: /v2/subscriptions/5b082dc2c17960f8773dd74d
< Fiware-Correlator: 8dd38278-6031-11e8-b6dc-000c29173617
< Date: Fri, 25 May 2018 15:37:38 GMT
< 
* Connection #0 to host localhost left intact
...