[Backlogmanager] [FIWARE-JIRA] (HELP-14008) [fiware-stackoverflow] Non-Primitive Values from a Registered Content Provider are not showing a value

FW External User (JIRA) jira-help-desk at jira.fiware.org
Mon Apr 23 17:03:00 CEST 2018


     [ https://jira.fiware.org/browse/HELP-14008?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

FW External User updated HELP-14008:
------------------------------------

Actually I’ve discovered the issue is worse than I thought.

If I have an Entity with an existing object attribute in Orion (e.g.Postal Address)
And then I add in **any** field into the context (e.g. a Number for temperature) then the Object attribute appears as "" when the Entity is requested:

e.g.:


curl -X POST \
  'http://localhost:1026/v2/op/update' \
  -H 'Content-Type: application/json' \
  -g -d '{
  "actionType": "APPEND",
  "entities": [
  	{
  		"id":"urn:ngsi-ld:Store:004","type":"Store",
  		"address":{"type":"PostalAddress","value":{"streetAddress":"Panoramastraße 1A","addressRegion":"Berlin","addressLocality":"Mitte","postalCode":"10178"}},
  		"location":{"type":"geo:json","value":{"type":"Point","coordinates":[13.4094,52.5208]}},
  		"name":{"type":"Text","value":"Tower Trödelmarkt"}
  	}
  ]
}’

curl -X POST \
  'http://localhost:1026/v2/registrations' \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json' \
  -d '{
  "description": "Relative Humidity Context Source",
  "dataProvided": {
    "entities": [
      {
        "id": "urn:ngsi-ld:Store:004",
        "type": "Store"
      }
    ],
    "attrs": [
      "temperature"
    ]
  },
  "provider": {
    "http": {
      "url": "http://context-provider:3000/proxy/random/number/temperature"
    },
     "legacyForwarding": true
  }
}’

curl -X GET \
  'http://localhost:1026/v2/entities/urn:ngsi-ld:Store:004'



Response:


{
    "id": "urn:ngsi-ld:Store:004",
    "type": "Store",
    "address": {
        "type": "PostalAddress",
        "value": "",
        "metadata": {}
    },
    "location": {
        "type": "geo:json",
        "value": "",
        "metadata": {}
    },
    "name": {
        "type": "Text",
        "value": "Tower Trödelmarkt",
        "metadata": {}
    },
    "temperature": {
        "type": "Number",
        "value": "29",
        "metadata": {}
    }
}


Postal Address has disappeared.


I would add this to the JIRA ticket, but I don’t have a log-in.


Regards,

Jason.










> [fiware-stackoverflow] Non-Primitive Values from a Registered Content Provider are not showing a value
> ------------------------------------------------------------------------------------------------------
>
>                 Key: HELP-14008
>                 URL: https://jira.fiware.org/browse/HELP-14008
>             Project: Help-Desk
>          Issue Type: Monitor
>          Components: FIWARE-TECH-HELP
>            Reporter: Backlog Manager
>            Assignee: Jose Manuel Cantera
>              Labels: arrays, fiware, fiware-orion, json
>
> Created question in FIWARE Q/A platform on 20-04-2018 at 17:04
> {color: red}Please, ANSWER this question AT{color} https://stackoverflow.com/questions/49945250/non-primitive-values-from-a-registered-content-provider-are-not-showing-a-value
> +Question:+
> Non-Primitive Values from a Registered Content Provider are not showing a value
> +Description:+
> I'm using the /v2/registrations endpoint to register a content provider with the legacyForwarding flag being set. Therefore my Content Provider is offering the v1/queryContext endpoint
> When I am returning a simple value (Integer, String etc.) such as a temperature the data is added to the context correctly:
> {
>     "contextResponses": [
>         {
>             "contextElement": {
>                 "attributes": [
>                     {
>                         "name": "temperature",
>                         "type": "Number",
>                         "value": 27
>                     }
>                 ],
>                 "id": "urn:ngsi-ld:Store:001",
>                 "isPattern": "false",
>                 "type": "Store"
>             },
>             "statusCode": {
>                 "code": "200",
>                 "reasonPhrase": "OK"
>             }
>         }
>     ]
> }
> However when trying to return an array of strings as shown from a Context Provider.
> {
>     "contextResponses": [
>         {
>             "contextElement": {
>                 "attributes": [
>                     {
>                         "name": "tweets",
>                         "type": "Array",
>                         "value": [
>                             "String 1",
>                             "String 2"
>                         ]
>                     }
>                 ],
>                 "id": "urn:ngsi-ld:Store:002",
>                 "isPattern": "false",
>                 "type": "Store"
>             },
>             "statusCode": {
>                 "code": "200",
>                 "reasonPhrase": "OK"
>             }
>         }
>     ]
> }
> I can see the request being sent in the log and I can retrieve the following entity:
> {
>     "id": "urn:ngsi-ld:Store:002",
>     "type": "Store",
>     "address": {
>         "type": "PostalAddress",
>         "value": "",
>         "metadata": {}
>     },
>     "location": {
>         "type": "geo:json",
>         "value": "",
>         "metadata": {}
>     },
>     "name": {
>         "type": "Text",
>         "value": "Checkpoint Markt",
>         "metadata": {}
>     },
>     "tweets": {
>         "type": "Array",
>         "value": "",
>         "metadata": {}
>     }
> }
> As you can see the "tweets" value is blank, but the attribute  exists and the type has been successfully received. 
> My question is how should I return an Array or an Object as a value from a Content Provider so that Orion is able to display the data received correctly? 



--
This message was sent by Atlassian JIRA
(v6.4.1#64016)


More information about the Backlogmanager mailing list

You can get more information about our cookies and privacy policies clicking on the following links: Privacy policy   Cookies policy