Search code examples
apirequestiotfiware

Fiware IoT Agent Json refused to POST to /v2/op/update


I am interested in fiware IoT Agent JSON, and i tried to work things out. I've mange to install the IoT Agent JSON using this tutorial. The tutorial refers about IoT Actuator Connection and to check the connection we have to POST to {IoTAgentIP:Port}/v2/op/update. When I post to this endpoint I get:

<html lang="en">

<head>
   <meta charset="utf-8">
   <title>Error</title>
</head>

<body>
   <pre>Cannot POST /v2/op/update</pre>
</body>

</html>

My Post Command Is:

curl -iX POST \
  http://localhost:4041/v2/op/update \
  -H 'Content-Type: application/json' \
  -H 'fiware-service: openiot' \
  -H 'fiware-servicepath: /' \
  -d '{
    "actionType": "update",
    "entities": [
        {
            "type": "Alarm",
            "id": "urn:ngsi-ld:Alarm:001",
            "ring" : {
                "type": "command",
                "value": ""
            }
        }
    ]
}'

And

curl -iX POST \
  http://localhost:4041/v2/op/update \
  -H 'Content-Type: application/json' \
  -H 'fiware-service: openiot' \
  -H 'fiware-servicepath: /' \
  -d '{
    "actionType": "update",
    "entities": [
        {
            "type": "Bell",
            "id": "urn:ngsi-ld:Bell:001",
            "ring" : {
                "type": "command",
                "value": ""
            }
        }
    ]
}'

My IoT agent version is:

{
    "libVersion": "2.12.0-next",
    "port": 4041,
    "baseRoot": "/",
    "version": "1.14.0-next"
}

Update - With latest Version of IoTA and orion I get in the IoTA log File the below:

time=2020-10-22T20:46:49.063Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.DeviceService | srv=n/a | subsrv=n/a | msg=Creating initial entity in the Context Broker:
 {
    "url": "http://localhost:1026/v1/updateContext",
    "method": "POST",
    "json": {
        "contextElements": [
            {
                "type": "Bell",
                "isPattern": "false",
                "id": "urn:ngsi-ld:Bell:001",
                "attributes": [
                    {
                        "name": "refStore",
                        "type": "Relationship",
                        "value": "urn:ngsi-ld:Store:001"
                    },
                    {
                        "name": "ring_status",
                        "type": "commandStatus",
                        "value": "UNKNOWN"
                    },
                    {
                        "name": "ring_info",
                        "type": "commandResult",
                        "value": " "
                    },
                    {
                        "name": "TimeInstant",
                        "type": "ISO8601",
                        "value": " "
                    }
                ]
            }
        ],
        "updateAction": "APPEND"
    },
    "headers": {
        "fiware-service": "openiot",
        "fiware-servicepath": "/",
        "fiware-correlator": "7c9fba8d-9262-4f81-9b4e-f71ab57953ff"
    }
} | comp=IoTAgent
time=2020-10-22T20:46:49.063Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.DeviceService | srv=n/a | subsrv=n/a | msg=executeWithSecurity | comp=IoTAgent
time=2020-10-22T20:46:49.063Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.MongoDBGroupRegister | srv=n/a | subsrv=n/a | msg=Looking for group params ["type"] with queryObj {"type":"Bell"} | comp=IoTAgent
time=2020-10-22T20:46:49.069Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.MongoDBGroupRegister | srv=n/a | subsrv=n/a | msg=Device group for fields [["type"]] not found: [{"type":"Bell"}] | comp=IoTAgent
time=2020-10-22T20:46:49.069Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.DeviceService | srv=n/a | subsrv=n/a | msg=error {"name":"DEVICE_GROUP_NOT_FOUND","message":"Couldn\t find device group for fields: [\"type\"] and values: {\"type\":\"Bell\"}","code":404} in get group device | comp=IoTAgent
time=2020-10-22T20:46:49.097Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.DeviceService | srv=n/a | subsrv=n/a | msg=Initial entity created successfully. | comp=IoTAgent

Solution

  • I manage to make it to work with one service group (/iot/d). So Post requests to append a sensor goes from /iot/d service group. I use docker images (compiled with docker compose, like the example). I also have modified in docker file the IOTA_DEFAULT_RESOURCE just in case to be: IOTA_DEFAULT_RESOURCE= I've used the latest IoT Agent JSON 1.15.0 and the previous Version 2.4.0 of Orion.