I have a small problem. Im doing a subscription to Orion Context Broker and I have a strange problem with URL of callback: this code works from tutorial:
{
"entities": [
{
"type": "Room",
"isPattern": "false",
"id": "Room1"
}
],
"attributes": [
"temperature"
],
"reference": "http://localhost:1028/accumulate",
"duration": "P1M",
"notifyConditions": [
{
"type": "ONTIMEINTERVAL",
"condValues": [
"PT10S"
]
}
]
}
But this code doesnt work:
{
"entities": [
{
"type": "Room",
"isPattern": "false",
"id": "Room1"
}
],
"attributes": [
"temperature"
],
"reference": "http://192.168.1.12:1028/accumulate?name=dupex",
"duration": "P1M",
"notifyConditions": [
{
"type": "ONTIMEINTERVAL",
"condValues": [
"PT10S"
]
}
]
}
Only difference is reference field: "reference": "192.168.1.12:1028/accumulate?name=dupex"
I got:
{
"subscribeError": {
"errorCode": {
"code": "400",
"reasonPhrase": "Bad Request",
"details": "Illegal value for JSON field"
}
}
}
Any Suggestion please :) thank you.
The root cause of the problem is that
=
is a forbidden character, not allowed in payload request for security reasons (see this section in the user manual about it).There are two possible workarounds:
http://192.168.1.12:1028/accumulate/name/dupex
.=
is%3D
) and prepare your code to decode it.In case 2, you could use the follwoing reference in subscribeContext:
http://192.168.1.12:1028/accumulate?name%3Ddupex
. Then, an example of code that will take into account the encoding and get thename
argument properly would be the following (written in Python using Flask as REST server framework):I guess that a similar approach can be used in other languages (Java, Node, etc.).
EDIT: Orion version 1.2 support notification customization in the NGSIv2, which allows this use case. For example, you can define the following subscriptions:
Please have a look to "Subscriptions" and "Custom Notifications" sections at NGSIv2 Specification for details.