You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

关于/type/<type>/id/<id>模式的使用方法及NGSI v2兼容性问询

Orion Context Broker: /type/<type>/id/<id> Pattern Usage & NGSI v2 Support

Great question! Let's break this down clearly based on Orion Context Broker's behavior:

1. How to use the /type/<type>/id/<id> URL pattern

This pattern is built for NGSI 9/10 (v1 API) to explicitly target entities with a specific type, fixing the ambiguity that can come with the default empty-type implicit behavior. Here's how to apply it across common operations:

  • Retrieve an entity's context: Send a GET request to the full path. For example, to fetch a Car entity with ID Car123, the URL would be:

    GET /v1/contextEntities/type/Car/id/Car123
    

    This guarantees you're only accessing the entity of type Car with that ID—critical if another entity (like a Truck) shares the same ID.

  • Update an entity's attributes: Use a POST request to the attributes subpath of the pattern. For instance, to update the speed attribute of the same Car entity:

    POST /v1/contextEntities/type/Car/id/Car123/attributes
    

    Include the updated attribute data in the request body following NGSI v1 format.

  • Delete an entity: Send a DELETE request to the entity path:

    DELETE /v1/contextEntities/type/Car/id/Car123
    

In short, this pattern replaces the default empty-type segment in v1's convenience operations with an explicit type value, making your entity targeting precise and unambiguous.

2. Does this pattern support NGSI v2?

No, the /type/<type>/id/<id> pattern is exclusive to NGSI v1 (NGSI9/10). NGSI v2 uses a more streamlined API design where entity uniqueness is defined by the combination of id and type, and it uses a different approach to specify the type:

  • To target a specific entity by id and type in NGSI v2, use the base entity path with a type query parameter. For example, retrieving the same Car123 entity:
    GET /v2/entities/Car123?type=Car
    
  • When creating or updating entities in v2, you include the type directly in the request body (as part of the entity JSON structure), rather than embedding it in the URL path.

NGSI v2's design eliminates the need for the v1-style URL pattern by integrating type as a core part of the entity's identity, handled either via query parameters or request body fields.

内容的提问来源于stack exchange,提问作者Júlio Zinga

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 09:03:41