11-06-2013 06:01 PM
Here's my setup:
With that setup I do a GET /nuxeo/api/v1/path/default-domain/workspaces/ws/mydocinstance and get the following JSON:
{
...
"myschema:list":[
{
"foo":"test1",
"bar":"test2"
}
]
...
}
Now POST to the same API to create a new document: POST /nuxeo/api/v1/path/default-domain/workspaces/ws/mynewinstance
{
...
"myschema:list":[
{
"foo":"testA",
"bar":"testB"
}
]
...
}
Up to this point, everything looks good, but the problem appears when I GET that new document, e.g. GET /nuxeo/api/v1/path/default-domain/workspaces/ws/mynewinstance and I get:
{
...
"myschema:list":[]
...
}
Why do the myschema:foo and myschema:bar sub-properties get ignored in JSON POSTed?
11-07-2013 11:09 AM
Fun, answering my own questions! k, this one took some time, but thanks to Nuxeo DM source being freely available and a debugger, I can now do what i was trying to do!
First off, the TL;DR solution: All fields in the JSON nxentity "properties" map MUST be strings, thus if you are trying to set a complex property, the JSON structure of that complex property MUST be escaped.
For example, in my examples above, I need to escape the JSON subtree of the "myschema:list" property so what gets PUT to the REST API should be:
{
"properties": {
"myschema:list": "[{\"foo\":\"myfoo\",\"bar\":\"mybar\"}]"
}
}
UPDATE: I'm editing my original answer since the Nuxeo folks have fixed this behavior with hotfix release nuxeo-5.8.0-HF01-1.0.0. This update should not require the treatment of the complex fields as strings.
11-07-2013 11:37 AM
That's not supposed to be the case. You should get proper and readable JSON. I'll raise the issue internally.
11-07-2013 11:57 AM
This behavior seems to only be the case when sending the JSON nxentity via PUT or POST. On a GET request, the JSON that is returned is "sane" and doesn't require this kind of escaping.
11-07-2013 12:07 PM
Ok but you should be able to send normal JSON as well. That's the goal of these new APIs.
11-08-2013 11:31 AM
I've created a ticket here
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.