Gianmarco Biscini
Gianmarco Biscini

Reputation: 435

Creating two identical entities on Fiware Orion

If I create two identical entities on Fiware Orion: same name, same id and same attributes, what is the behaviour of the system?. Does it do just an update?

Upvotes: 1

Views: 116

Answers (2)

Jose Manuel Cantera
Jose Manuel Cantera

Reputation: 853

if you don't want to care whether the entity is created or just updated you can use the batch operation

POST /v2/op/update

with action type 'REPLACE' see https://github.com/Fiware/dataModels/blob/master/Weather/WeatherObserved/harvest/portugal_weather_observed_harvest.py#L149

You may also use action type 'APPEND'. The only caveat of that approach is that if the entity contains old attributes, they will remain ...

What the API does not support is an UPSERT operation ... i.e. the /v2/op/update would only work if the entity already exists ...

Upvotes: 1

fgalan
fgalan

Reputation: 12322

Orion will not let you to create two entities with the same id and type in the same service path. If you try to do that you will get an error like this one:

{
    "error": "Unprocessable",
    "description": "Already Exists"
}

Upvotes: 1

Related Questions