vaimee / zion

A scalable Thing Description Directory
Apache License 2.0
17 stars 4 forks source link

No assigned _id on POST CREATE #3

Closed FerrariAndrea closed 2 years ago

FerrariAndrea commented 2 years ago

Hi, The post call for a creation of a new TD is working, but it is not generating any _id to assign at the TD. Below is a curl example of CREATE (using the authentication, pls replace the Bearer token):

curl --location --request POST 'http://localhost:3000/things' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjEsImlhdCI6MTY1NzAyMTE4MiwiZXhwIjoxNjU3MDIyMDgyfQ.kxCnnuJLVWVVtOKChcoBw7THXqmiv2onaFtRMQcNd5c' \
--header 'Content-Type: application/json' \
--data-raw '{"@context":["http://www.w3.org/ns/td","https://context.dasibreaker.vaimee.it/context.jsonld",{"@language":"en"}],"@type":["Sensor"],"title":"temp_02","securityDefinitions":{"no_sec":{"scheme":"nosec"}},"security":"no_sec","properties":{"latitude":{"title":"Latitude","description":"Latitude of the sensor","@type":"xsd:float","readOnly":false,"writeOnly":false,"observable":false,"forms":[{"href":"http://15.0.0.2:8080/temp_02/properties/latitude","contentType":"application/json","op":["readproperty","writeproperty"]},{"href":"http://192.168.80.1:8080/temp_02/properties/latitude","contentType":"application/json","op":["readproperty","writeproperty"]},{"href":"coap://15.0.0.2:5683/temp_02/properties/latitude","contentType":"application/json","op":["readproperty","writeproperty"]},{"href":"coap://192.168.80.1:5683/temp_02/properties/latitude","contentType":"application/json","op":["readproperty","writeproperty"]}]},"longitude":{"title":"Longitude","description":"Longitude of the sensor","@type":"xsd:float","readOnly":false,"writeOnly":false,"observable":false,"forms":[{"href":"http://15.0.0.2:8080/temp_02/properties/longitude","contentType":"application/json","op":["readproperty","writeproperty"]},{"href":"http://192.168.80.1:8080/temp_02/properties/longitude","contentType":"application/json","op":["readproperty","writeproperty"]},{"href":"coap://15.0.0.2:5683/temp_02/properties/longitude","contentType":"application/json","op":["readproperty","writeproperty"]},{"href":"coap://192.168.80.1:5683/temp_02/properties/longitude","contentType":"application/json","op":["readproperty","writeproperty"]}]},"value":{"title":"Sensor value","description":"Sensor value","@type":"xsd:float","readOnly":false,"writeOnly":false,"observable":false,"forms":[{"href":"http://15.0.0.2:8080/temp_02/properties/value","contentType":"application/json","op":["readproperty","writeproperty"]},{"href":"http://192.168.80.1:8080/temp_02/properties/value","contentType":"application/json","op":["readproperty","writeproperty"]},{"href":"coap://15.0.0.2:5683/temp_02/properties/value","contentType":"application/json","op":["readproperty","writeproperty"]},{"href":"coap://192.168.80.1:5683/temp_02/properties/value","contentType":"application/json","op":["readproperty","writeproperty"]}]}},"forms":[{"href":"http://15.0.0.2:8080/temp_02/all/properties","contentType":"application/json","op":["writeallproperties","writemultipleproperties"]},{"href":"http://192.168.80.1:8080/temp_02/all/properties","contentType":"application/json","op":["writeallproperties","writemultipleproperties"]}]}'

That request has a response: 201 created Then if I ask for a get-all like that: curl --location --request GET 'http://localhost:3000/things' The TD exists but with not _id:

[
    {
        "@type": [
            "Sensor"
        ],
        "forms": [
            {
                "op": [
                    "writeallproperties",
                    "writemultipleproperties"
                ],
                "href": "http://15.0.0.2:8080/temp_02/all/properties",
                "contentType": "application/json"
            },
            {
                "op": [
                    "writeallproperties",
                    "writemultipleproperties"
                ],
                "href": "http://192.168.80.1:8080/temp_02/all/properties",
                "contentType": "application/json"
            }
        ],
        "title": "temp_02",
        "@context": [
            "http://www.w3.org/ns/td",
            "https://context.dasibreaker.vaimee.it/context.jsonld",
            {
                "@language": "en"
            }
        ],
        "security": "no_sec",
        "properties": {
            "value": {
                "@type": "xsd:float",
                "forms": [
                    {
                        "op": [
                            "readproperty",
                            "writeproperty"
                        ],
                        "href": "http://15.0.0.2:8080/temp_02/properties/value",
                        "contentType": "application/json"
                    },
                    {
                        "op": [
                            "readproperty",
                            "writeproperty"
                        ],
                        "href": "http://192.168.80.1:8080/temp_02/properties/value",
                        "contentType": "application/json"
                    },
                    {
                        "op": [
                            "readproperty",
                            "writeproperty"
                        ],
                        "href": "coap://15.0.0.2:5683/temp_02/properties/value",
                        "contentType": "application/json"
                    },
                    {
                        "op": [
                            "readproperty",
                            "writeproperty"
                        ],
                        "href": "coap://192.168.80.1:5683/temp_02/properties/value",
                        "contentType": "application/json"
                    }
                ],
                "title": "Sensor value",
                "readOnly": false,
                "writeOnly": false,
                "observable": false,
                "description": "Sensor value"
            },
            "latitude": {
                "@type": "xsd:float",
                "forms": [
                    {
                        "op": [
                            "readproperty",
                            "writeproperty"
                        ],
                        "href": "http://15.0.0.2:8080/temp_02/properties/latitude",
                        "contentType": "application/json"
                    },
                    {
                        "op": [
                            "readproperty",
                            "writeproperty"
                        ],
                        "href": "http://192.168.80.1:8080/temp_02/properties/latitude",
                        "contentType": "application/json"
                    },
                    {
                        "op": [
                            "readproperty",
                            "writeproperty"
                        ],
                        "href": "coap://15.0.0.2:5683/temp_02/properties/latitude",
                        "contentType": "application/json"
                    },
                    {
                        "op": [
                            "readproperty",
                            "writeproperty"
                        ],
                        "href": "coap://192.168.80.1:5683/temp_02/properties/latitude",
                        "contentType": "application/json"
                    }
                ],
                "title": "Latitude",
                "readOnly": false,
                "writeOnly": false,
                "observable": false,
                "description": "Latitude of the sensor"
            },
            "longitude": {
                "@type": "xsd:float",
                "forms": [
                    {
                        "op": [
                            "readproperty",
                            "writeproperty"
                        ],
                        "href": "http://15.0.0.2:8080/temp_02/properties/longitude",
                        "contentType": "application/json"
                    },
                    {
                        "op": [
                            "readproperty",
                            "writeproperty"
                        ],
                        "href": "http://192.168.80.1:8080/temp_02/properties/longitude",
                        "contentType": "application/json"
                    },
                    {
                        "op": [
                            "readproperty",
                            "writeproperty"
                        ],
                        "href": "coap://15.0.0.2:5683/temp_02/properties/longitude",
                        "contentType": "application/json"
                    },
                    {
                        "op": [
                            "readproperty",
                            "writeproperty"
                        ],
                        "href": "coap://192.168.80.1:5683/temp_02/properties/longitude",
                        "contentType": "application/json"
                    }
                ],
                "title": "Longitude",
                "readOnly": false,
                "writeOnly": false,
                "observable": false,
                "description": "Longitude of the sensor"
            }
        },
        "securityDefinitions": {
            "no_sec": {
                "scheme": "nosec"
            }
        }
    }
]

Thx :)