Skip to content

Response payload body is missing for batch upsert. #502

@jason-fox

Description

@jason-fox

I make a batch create operation

curl -L -X POST 'http://localhost:1026/ngsi-ld/v1/entityOperations/create' \
-H 'Content-Type: application/json' \
-H 'Link: <http://context-provider:3000/data-models/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
-H 'Accept: application/ld+json' \
--data-raw '[
    {
      "id": "urn:ngsi-ld:TemperatureSensor:002",
      "type": "TemperatureSensor",
      "category": {
            "type": "Property",
            "value": "sensor"
      },
      "temperature": {
            "type": "Property",
            "value": 20,
            "unitCode": "CEL"
      }
    },
    {
      "id": "urn:ngsi-ld:TemperatureSensor:003",
      "type": "TemperatureSensor",
      "category": {
            "type": "Property",
            "value": "sensor"
      },
      "temperature": {
            "type": "Property",
            "value": 2,
            "unitCode": "CEL"
      }
    },
     {
      "id": "urn:ngsi-ld:TemperatureSensor:004",
      "type": "TemperatureSensor",
      "category": {
            "type": "Property",
            "value": "sensor"
      },
      "temperature": {
            "type": "Property",
            "value": 100,
            "unitCode": "CEL"
      }
    }
]'

The broker returns a payload detailing success/failure - this is CORRECT

EITHER:

{
    "@context": "http://context-provider:3000/data-models/ngsi-context.jsonld",
    "success": [
        "urn:ngsi-ld:TemperatureSensor:002",
        "urn:ngsi-ld:TemperatureSensor:003",
        "urn:ngsi-ld:TemperatureSensor:004"
    ],
    "errors": []
}

OR:

{
    "@context": "http://context-provider:3000/data-models/ngsi-context.jsonld",
    "success": [],
    "errors": [
        {
            "entityId": "urn:ngsi-ld:TemperatureSensor:002",
            "error": {
                "type": "https://uri.etsi.org/ngsi-ld/errors/BadRequestData",
                "title": "entity already exists",
                "status": 400
            }
        },
        {
            "entityId": "urn:ngsi-ld:TemperatureSensor:003",
            "error": {
                "type": "https://uri.etsi.org/ngsi-ld/errors/BadRequestData",
                "title": "entity already exists",
                "status": 400
            }
        },
        {
            "entityId": "urn:ngsi-ld:TemperatureSensor:004",
            "error": {
                "type": "https://uri.etsi.org/ngsi-ld/errors/BadRequestData",
                "title": "entity already exists",
                "status": 400
            }
        }
    ]
}

I now batch upsert the same entities:

curl -L -X POST 'http://localhost:1026/ngsi-ld/v1/entityOperations/upsert' \
-H 'Content-Type: application/json' \
-H 'Link: <http://context-provider:3000/data-models/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
-H 'Accept: application/ld+json' \
-H 'Cookie: _csrf=MAPTGFPcoPnewsGCWklHi4Mq' \
--data-raw '[
    {
      "id": "urn:ngsi-ld:TemperatureSensor:002",
      "type": "TemperatureSensor",
      "category": {
            "type": "Property",
            "value": "sensor"
      },
      "temperature": {
            "type": "Property",
            "value": 21,
            "unitCode": "CEL"
      }
    },
    {
      "id": "urn:ngsi-ld:TemperatureSensor:003",
      "type": "TemperatureSensor",
      "category": {
            "type": "Property",
            "value": "sensor"
      },
      "temperature": {
            "type": "Property",
            "value": 27,
            "unitCode": "CEL"
      }
    }
]'

The response is 204 no content - this is INCORRECT

According to the 1.3.1 specification: 5.6.8 Batch Entity Creation or Update (Upsert)

5.6.8.5 Output data

  • The list of Entities successfully processed (S Array).
  • The list of Entities in error (E Array).

The response payload body is missing, and the HTTP code should be altered since content should be returned.

"git_hash": "db891a72a531ef4cc037caed5b04f8fe71da6814",
"compile_time": "Thu Jul 30 13:13:23 UTC 2020"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions