简体   繁体   中英

Subscription in Orion Context Broker Fiware

I try to send a subscription to my Orion Context Broker instance. I'm sending this JSON:

{
  "duration": "P1M",
  "reference": "http://130.206.127.23:1026/ngsi10/notifyContext",
  "notifyConditions": [
    {
      "condValues": [
        "PT10s"
      ],
      "type": "ONTIMEINTERVAL"
    }
  ],
  "entities": [
    {
      "id": "1.0",
      "type": "Capsule",
      "isPattern": "false"
    }
  ],
  "attributes": [
    "temperature"
  ]
}

And I receive the next message:

<subscribeContextResponse>
  <subscribeError>
    <errorCode>
      <code>400</code>
      <reasonPhrase>Bad Request</reasonPhrase>
      <details>JSON Parse Error: <unspecified file>(1): invalid escape sequence</details>
    </errorCode>
  </subscribeError>
</subscribeContextResponse>

I put all attributes that it is using in the documentation . But in the webinar Orion Context Broker Webinar - Demo part 2 I can see other attribute called Throttling , but I don't see in the documentation.

What I'm doing bad?

Thanks in advance.

I have tested with your request (copy-pasted) and this is the result (with Orion 0.17.0).

Command (you can check that the payload is exactly the one you used):

(curl localhost:1026/v1/subscribeContext -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' -d @- | python -mjson.tool) <<EOF
{
  "duration": "P1M",
  "reference": "http://130.206.127.23:1026/ngsi10/notifyContext",
  "notifyConditions": [
    {
      "condValues": [
        "PT10s"
      ],
      "type": "ONTIMEINTERVAL"
    }
  ],
  "entities": [
    {
      "id": "1.0",
      "type": "Capsule",
      "isPattern": "false"
    }
  ],
  "attributes": [
    "temperature"
  ]
}
EOF

Result:

{
    "subscribeResponse": {
        "duration": "P1M", 
        "subscriptionId": "5489e0bfe5007d3271ab5a61"
    }
}

Thus, my test was ok so I tend to think that the problem is related with encoding and it is not shown in your question post, eg the usage of (wrong) intead of " and things like that.

EDIT: another common source of problems is using script files containing the curl request to CB in "DOS text" (typically due to the usage of DOS/Windows text editors). This can be easility detected if you run file yourfile.sh and get the following

yourfile.sh: ASCII text, with CRLF line terminators

instead of the following

yourfile.sh: ASCII text

The solution is quite simple: transform the file to "Unix text", for example using the dos2unix command line tool.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM