简体   繁体   中英

Using HTTP API and json to insert an embedded type in OrientDB

I have defined a class 'Box' in OrientDB using the schema manager in studio. 'Box' has only one element - an embedded class 'Label'.

When I use this json to create a label

 {
    "@class": "Label",
        "boxUUID": "azxc",
        "validFrom": 0,
        "validTo": 100
}

in a POST command to 'Label', the insert works.

But when I use it as below in a POST to 'Box' it fails.

{
    "@class": "Box",
    "Label": {
        "boxUUID": "azxc",
        "validFrom": 0,
        "validTo": 100
    }
}

With the following error message:

{
  "errors": [
    {
      "reason": 500,
      "content": "com.orientechnologies.orient.core.exception.OValidationException: The field 'Box.Label' has been declared as EMBEDDED but an incompatible type is used. Value: {boxUUID=azxc, validFrom=0, validTo=100}",
      "code": 500
    }
  ]
}

What is the correct format of the json for a class with an embedded class in OrientDB over the HTTP API?

The correct command is:

  • Put in the URL: localhost: 2480 / document / "your database name"
  • Put in json "@" + name embedded class

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM