<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Problem with document creation REST API: document JSON properties in a collection are ignored in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/problem-with-document-creation-rest-api-document-json-properties/m-p/321376#M8377</link>
    <description>&lt;P&gt;I've created a ticket here&lt;/P&gt;</description>
    <pubDate>Fri, 08 Nov 2013 16:31:27 GMT</pubDate>
    <dc:creator>Damien_Metzler</dc:creator>
    <dc:date>2013-11-08T16:31:27Z</dc:date>
    <item>
      <title>Problem with document creation REST API: document JSON properties in a collection are ignored</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/problem-with-document-creation-rest-api-document-json-properties/m-p/321371#M8372</link>
      <description>&lt;P&gt;Here's my setup:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;schema "myschema" defined as single field named "list" of type Complex that is multi-valued&lt;/LI&gt;
&lt;LI&gt;the complex sub-schema has 2 string fields "foo" and "bar", neither are multi-valued&lt;/LI&gt;
&lt;LI&gt;document type "mydoc" that references this schema&lt;/LI&gt;
&lt;LI&gt;modify creation/edit layouts for the document type to use a list widget on the "myschema" schema&lt;/LI&gt;
&lt;LI&gt;in Nuxeo DM, create a "mydoc" document titled "mydocinstance" (for testing, i hit the "Add" trigger on the UI and plug in the values "test1" and "test2" for the foo/bar fields respectively)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;With that setup I do a   GET /nuxeo/api/v1/path/default-domain/workspaces/ws/mydocinstance and get the following JSON:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;{
...
  "myschema:list":[
     {
     "foo":"test1",
     "bar":"test2"
     }
  ]
...
}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now POST to the same API to create a new document:
POST /nuxeo/api/v1/path/default-domain/workspaces/ws/mynewinstance&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;{
...
   "myschema:list":[
         {
         "foo":"testA",
         "bar":"testB"
         }
      ]
    ...
    }
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;{
    ...
       "myschema:list":[]
     ...
}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Why do the myschema:foo and myschema:bar sub-properties get ignored in JSON POSTed?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2013 23:01:02 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/problem-with-document-creation-rest-api-document-json-properties/m-p/321371#M8372</guid>
      <dc:creator>russtrotter_</dc:creator>
      <dc:date>2013-11-06T23:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with document creation REST API: document JSON properties in a collection are ignored</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/problem-with-document-creation-rest-api-document-json-properties/m-p/321372#M8373</link>
      <description>&lt;P&gt;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!&lt;/P&gt;
&lt;P&gt;First off, the TL;DR solution:  All fields in the JSON nxentity "properties" map &lt;STRONG&gt;MUST&lt;/STRONG&gt; be strings, thus if you are trying to set a complex property, the JSON structure of that complex property &lt;STRONG&gt;MUST&lt;/STRONG&gt; be escaped.&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;{
    "properties": {
        "myschema:list": "[{\"foo\":\"myfoo\",\"bar\":\"mybar\"}]"
    }
}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;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 &lt;STRONG&gt;not&lt;/STRONG&gt; require the treatment of the complex fields as strings.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2013 16:09:50 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/problem-with-document-creation-rest-api-document-json-properties/m-p/321372#M8373</guid>
      <dc:creator>russtrotter_</dc:creator>
      <dc:date>2013-11-07T16:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with document creation REST API: document JSON properties in a collection are ignored</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/problem-with-document-creation-rest-api-document-json-properties/m-p/321373#M8374</link>
      <description>&lt;P&gt;That's not supposed to be the case. You should get proper and readable JSON. I'll raise the issue internally.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2013 16:37:53 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/problem-with-document-creation-rest-api-document-json-properties/m-p/321373#M8374</guid>
      <dc:creator>Florent_Guillau</dc:creator>
      <dc:date>2013-11-07T16:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with document creation REST API: document JSON properties in a collection are ignored</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/problem-with-document-creation-rest-api-document-json-properties/m-p/321374#M8375</link>
      <description>&lt;P&gt;This behavior seems to only be the case when &lt;EM&gt;sending&lt;/EM&gt; 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.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2013 16:57:12 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/problem-with-document-creation-rest-api-document-json-properties/m-p/321374#M8375</guid>
      <dc:creator>russtrotter_</dc:creator>
      <dc:date>2013-11-07T16:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with document creation REST API: document JSON properties in a collection are ignored</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/problem-with-document-creation-rest-api-document-json-properties/m-p/321375#M8376</link>
      <description>&lt;P&gt;Ok but you should be able to send normal JSON as well. That's the goal of these new APIs.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2013 17:07:53 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/problem-with-document-creation-rest-api-document-json-properties/m-p/321375#M8376</guid>
      <dc:creator>Florent_Guillau</dc:creator>
      <dc:date>2013-11-07T17:07:53Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with document creation REST API: document JSON properties in a collection are ignored</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/problem-with-document-creation-rest-api-document-json-properties/m-p/321376#M8377</link>
      <description>&lt;P&gt;I've created a ticket here&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2013 16:31:27 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/problem-with-document-creation-rest-api-document-json-properties/m-p/321376#M8377</guid>
      <dc:creator>Damien_Metzler</dc:creator>
      <dc:date>2013-11-08T16:31:27Z</dc:date>
    </item>
  </channel>
</rss>

