POST dataObjectTree failure -- need typeInfoMap

Hello,

I am trying to make a post request. This is the body


[
  {

      "type": "CustodyResponse",

      "children": [
          {
              "dataObject": {
                  "type": "CustodyTask",
                  "assetId": "test"

              },
              "children": []
          }
      ]
    }
]


This is the metadataTemplate defining the parent/child relationship

<template name="AssetTemplate">
 ...
    <node type="PlanResponse" includeConcreteSubTypes="true">
        <node type="AbstractTask" includeConcreteSubTypes="true" />
    </node>
</template>

PlanResponse and AbstractTask are abstract.

<type type="CustodyResponse" edition="1" extends="PlanResponse-1"/>
<type type="CustodyTask" edition="1" extends="AbstractTask-1">

    <StringField  propName="assetId"
                  shortName="Asset ID"
                  defaultListed="true"
                  defaultLayoutIndex="1" />

</type>

I receive a 500 with this message. I’m not certain how to fill out the typeInfo map. Any suggestions? Thanks

"message": "Field (children) with unknown type present in JSON. Type info must be supplied in the typeInfo map, or a Global MetadataService must be registered with LeafPlugins that contains the BeanMetadata for the given DataObject type. (through reference chain: java.util.ArrayList[0])"

Hey there! I think the JSON for your tree is a little off. Basically trees are recursive, so the outer tree needs to be similar to the inner tree in that you need a field called dataObject. Here’s a sample:

[
  {
    "dataObject": {
      "type": "CustodyResponse"
    },
    "children": [
      {
        "dataObject": {
          "type": "CustodyTask",
          "assetId": "test"
        },
        "children": []
      }
    ]
  }
]

Also just a heads up, on newer versions of LEAF, children should be optional, so this will most likely work as well (and do the same thing).

[
  {
    "dataObject": {
      "type": "CustodyResponse"
    },
    "children": [
      {
        "dataObject": {
          "type": "CustodyTask",
          "assetId": "test"
        }
      }
    ]
  }
]

Also the error message seems to imply that you might be hitting an endpoint that accepts flat DataObjects rather than DataObjectTrees. Could you send the path you’re using?

Generally the POST should be to a path starting with /data-objects for plain DataObjects and /data-object-trees for trees.

1 Like

I’m on leaf ver 3.5, so I’m not sure if that is new enough to leave out children.

Here is the url – http://localhost:8080/pat-service/rest/data-objects?addType=NORMAL

That is probably the issue, because using the body you suggested resulted in this error "message": "DataObject JSON must contain a type attribute. (through reference chain: java.util.ArrayList[0])",

Try:

http://localhost:8080/pat-service/rest/data-object-trees?addType=NORMAL

that worked. Thanks again!

1 Like