Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type short name not recognized in an update operation. #507

Closed
jason-fox opened this issue Aug 24, 2020 · 4 comments
Closed

Type short name not recognized in an update operation. #507

jason-fox opened this issue Aug 24, 2020 · 4 comments

Comments

@jason-fox
Copy link
Member

I create three Data Entities:

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' \
-H 'Cookie: _csrf=MAPTGFPcoPnewsGCWklHi4Mq' \
--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"
      }
    }
]'

I then update two of them using an update operation as shown:

curl -L -X POST 'http://localhost:1026/ngsi-ld/v1/entityOperations/update?options=replace' \
-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 'Cookie: _csrf=MAPTGFPcoPnewsGCWklHi4Mq' \
--data-raw '[
  {
    "id": "urn:ngsi-ld:TemperatureSensor:003",
    "type": "https://uri.fiware.org/ns/data-models#TemperatureSensor",
    "category": {
      "type": "Property",
      "value": [
        "actuator",
        "sensor"
      ]
    }
  },
  {
    "id": "urn:ngsi-ld:TemperatureSensor:004",
    "type": "TemperatureSensor",
    "temperature": {
      "type": "Property",
      "value": [
        "actuator",
        "sensor"
      ]
    }
  }
]'

Both TemperatureSensor:003 and TemperatureSensor:004 exist so the expected result is 200 Success, but the actual response is: 207 Multi Status

{
    "@context": "http://context-provider:3000/data-models/ngsi-context.jsonld",
    "success": [
        "urn:ngsi-ld:TemperatureSensor:003"
    ],
    "errors": [
        {
            "entityId": "urn:ngsi-ld:TemperatureSensor:004",
            "error": {
                "type": "https://uri.etsi.org/ngsi-ld/errors/BadRequestData",
                "title": "non-matching entity type",
                "detail": "TemperatureSensor",
                "status": 400
            }
        }
    ]
}
"git_hash": "db891a72a531ef4cc037caed5b04f8fe71da6814",
"compile_time": "Thu Jul 30 13:13:23 UTC 2020"
@jason-fox
Copy link
Member Author

The @context used in the example can be found here.

@jason-fox
Copy link
Member Author

The same operation as an upsert works as expected - 204 No Content

POST http://localhost:1026/ngsi-ld/v1/entityOperations/upsert?options=replace

Although no body is found in the response - see #502

kzangeli added a commit that referenced this issue Sep 2, 2020
kzangeli added a commit that referenced this issue Sep 2, 2020
@kzangeli
Copy link
Collaborator

kzangeli commented Sep 2, 2020

Fixed by PR #513

@jason-fox
Copy link
Member Author

Verified: eddd375

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants