<?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: REST API creating document from an uploaded file fails with internal-error due to NPE in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/rest-api-creating-document-from-an-uploaded-file-fails-with/m-p/317679#M4680</link>
    <description>&lt;P&gt;Found the issue:
my JSON (above) spelled&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;"type" : "file"
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;instead of&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;"type" : "File"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 18 Nov 2016 21:59:46 GMT</pubDate>
    <dc:creator>Rafi_Cohen</dc:creator>
    <dc:date>2016-11-18T21:59:46Z</dc:date>
    <item>
      <title>REST API creating document from an uploaded file fails with internal-error due to NPE</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/rest-api-creating-document-from-an-uploaded-file-fails-with/m-p/317678#M4679</link>
      <description>&lt;P&gt;Hi, I am trying to upload a document to Nuxeo, which - according to the example in &lt;A href="https://www.nuxeo.com/blog/qa-friday-upload-files-documents-rest-api/"&gt;QA-Friday example&lt;/A&gt; is consisted of a 2-steps process:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;the 1st step, of uploading the file(s), works fine&lt;/LI&gt;
&lt;LI&gt;the 2nd step fails: I am trying to use the more capable API, which supports doc creation from multiple uploaded files (even though this test utilizes a single file), and as such - following the JSON structure and content of the example from QA-Friday:&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;&lt;CODE&gt;curl -X POST -H "Content-Type: application/json" -u Administrator:Administrator -d '{
    "entity-type" : "document",
    "name" : "myNewDoc2",
    "type" : "File",
    "properties" : {
        "dc:title" : "My new doc2",
        "files:files" : [
            { "file" : { "upload-batch" : "mybatchid", "upload-fileId" : "0"}, "filename" : "myFile.zip"},
            { "file" : { "upload-batch" : "mybatchid", "upload-fileId" : "1"}, "filename" : "myOtherFile.zip"}
        ]
    }
}' &lt;A href="http://localhost:8080/nuxeo/api/v1/path/default-domain/workspaces/workspace" target="test_blank"&gt;http://localhost:8080/nuxeo/api/v1/path/default-domain/workspaces/workspace&lt;/A&gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;my JSON looks like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;{ 
    "entity-type" : "document", 
    "name" : "UploadedFile00.txt",
    "properties" : {
        "dc:title" : "UploadedFile00.txt",
        "files:files" : [ {
            "file" : {
                "upload-batch" : "batchId-0d6800c3-6a8d-4c23-9361-4477dbe1376e",
                "upload-fileId" : "0"
            },
            "filename" : "UploadedFile00.txt"
        } ]
   },
   "type" : "file"
 }
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(with its details based on 1st/upload step) and yet it fails: response.toString():&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;InboundJaxrsResponse{context=ClientResponse{method=POST, uri=https://10.1.122.86:8082/nuxeo/api/v1/path/default-domain/workspaces, status=500, reason=Internal Server Error}}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And server.log:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;2016-11-15 11:39:10,654 DEBUG [http-bio-0.0.0.0-8082-exec-3] [org.nuxeo.ecm.core.transientstore.SimpleTransientStore] Fetched parameters from StorageEntry stored at key batchId-f8d5a74b-f215-44fc-9350-508ef8559a76: {0=batchId-f8d5a74b-f215-44fc-9350-508ef8559a76_0}

2016-11-15 11:39:10,654 DEBUG [http-bio-0.0.0.0-8082-exec-3] [org.nuxeo.ecm.automation.server.jaxrs.batch.Batch] Retrieving blob 0 for batch batchId-f8d5a74b-f215-44fc-9350-508ef8559a76

2016-11-15 11:39:10,654 DEBUG [http-bio-0.0.0.0-8082-exec-3] [org.nuxeo.ecm.core.transientstore.SimpleTransientStore] Fetched parameters from StorageEntry stored at key batchId-f8d5a74b-f215-44fc-9350-508ef8559a76_0: {chunked=false}

2016-11-15 11:39:10,654 DEBUG [http-bio-0.0.0.0-8082-exec-3] [org.nuxeo.ecm.core.transientstore.AbstractTransientStore] Loading blobs from the file system: [{file=YmF0Y2hJZC1mOGQ1YTc0Yi1mMjE1LTQ0ZmMtOTM1MC01MDhlZjg1NTlhNzZfMA==\34c372e1-6630-459e-a57b-68f574fc9ec0, filename=UploadedFile00.txt, mimetype=application/octet-stream}]

2016-11-15 11:39:10,654 DEBUG [http-bio-0.0.0.0-8082-exec-3] [org.nuxeo.runtime.transaction.TransactionHelper] Setting transaction as rollback only

2016-11-15 11:39:10,654 WARN  [http-bio-0.0.0.0-8082-exec-3] [org.nuxeo.ecm.webengine.app.WebEngineExceptionMapper] Exception in JAX-RS processing

java.lang.NullPointerException
 	at org.nuxeo.ecm.core.io.marshallers.json.document.DocumentModelJsonReader.applyAllPropertyValues(DocumentModelJsonReader.java:219)
 	at org.nuxeo.ecm.core.io.marshallers.json.document.DocumentModelJsonReader.readEntity(DocumentModelJsonReader.java:140)
	at org.nuxeo.ecm.core.io.marshallers.json.document.DocumentModelJsonReader.readEntity(DocumentModelJsonReader.java:78)
...
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Any idea what I am doing wrong/missing ?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2016 16:44:45 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/rest-api-creating-document-from-an-uploaded-file-fails-with/m-p/317678#M4679</guid>
      <dc:creator>Rafi_Cohen</dc:creator>
      <dc:date>2016-11-15T16:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: REST API creating document from an uploaded file fails with internal-error due to NPE</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/rest-api-creating-document-from-an-uploaded-file-fails-with/m-p/317679#M4680</link>
      <description>&lt;P&gt;Found the issue:
my JSON (above) spelled&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;"type" : "file"
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;instead of&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;"type" : "File"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Nov 2016 21:59:46 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/rest-api-creating-document-from-an-uploaded-file-fails-with/m-p/317679#M4680</guid>
      <dc:creator>Rafi_Cohen</dc:creator>
      <dc:date>2016-11-18T21:59:46Z</dc:date>
    </item>
  </channel>
</rss>

