REST API creating document from an uploaded file fails with internal-error due to NPE

Hi, I am trying to upload a document to Nuxeo, which - according to the example in QA-Friday example is consisted of a 2-steps process:

  • the 1st step, of uploading the file(s), works fine
  • 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:
    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"}
        ]
    }
    }' http://localhost:8080/nuxeo/api/v1/path/default-domain/workspaces/workspace
    
    my JSON looks like this:
    { 
    "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"
    }
    

(with its details based on 1st/upload step) and yet it fails: response.toString():

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}}

And server.log:

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)
...

Any idea what I am doing wrong/missing ?

0 votes

1 answers

212 views

ANSWER



Found the issue: my JSON (above) spelled

"type" : "file"

instead of

"type" : "File"
0 votes