Invalid argument exception. No doc type specified while tring to create nuxeo document with api rest Endpoint

For create file using Rest API (Nuxeo Platform 8.10 ), Postman I follow this link “https://doc.nuxeo.com/nxdoc/document-resources-endpoints/”

POST http://NUXEO_SERVER/nuxeo/api/v1/id/{idOfParentDoc}
{
    "entity-type": "document",
    "name":"newDoc",
    "type": "File",
    "properties": {
        "dc:title": "The new document",
        "dc:description": "Created via a very cool and easy REST API",
        "common:icon": "/icons/file.gif",
        "common:icon-expanded": null,
        "common:size": null
    }
}

But I am getting 500 exception – “invalid argument exception. No doc type specified” as Response. How to resolve this issue .

0 votes

2 answers

2768 views

ANSWER



Hi Amel,

I just did the test on a 8.10 with postman too and it seems to works. What I tested:

POST http://localhost:8080/nuxeo/api/v1/path//
{
    "entity-type": "document",
    "name":"newDoc",
    "type": "File",
    "properties": {
        "dc:title": "The new document",
        "dc:description": "Created via a very cool and easy REST API",
        "common:icon": "/icons/file.gif",
        "common:icon-expanded": null,
        "common:size": null
    }
}

I get the response:

{
    "entity-type": "document",
    "repository": "default",
    "uid": "34fb78e7-a114-4ad2-85ee-790200a6b60d",
    "path": "/newDoc",
    "type": "File",
    "state": "project",
    "parentRef": "dfc52762-a3dd-43df-9a8a-deebfec8a0ee",
    "isCheckedOut": true,
    "isVersion": false,
    "isProxy": false,
    "changeToken": "1504185758833",
    "title": "The new document",
    "lastModified": "2017-08-31T13:22:38.833Z",
    "facets": [
        "Versionable",
        "Publishable",
        "Commentable",
        "HasRelatedText",
        "Downloadable"
    ]
}

Same thing with the id url:

POST http://localhost:8080/nuxeo/api/v1/id/dfc52762-a3dd-43df-9a8a-deebfec8a0ee
{
    "entity-type": "document",
    "name":"newNewDoc",
    "type": "File",
    "properties": {
        "dc:title": "The new document",
        "dc:description": "Created via a very cool and easy REST API",
        "common:icon": "/icons/file.gif",
        "common:icon-expanded": null,
        "common:size": null
    }
}

I get the response:

{
    "entity-type": "document",
    "repository": "default",
    "uid": "3cd23391-f419-4a37-97db-b9215b26f4fc",
    "path": "/newNewDoc",
    "type": "File",
    "state": "project",
    "parentRef": "dfc52762-a3dd-43df-9a8a-deebfec8a0ee",
    "isCheckedOut": true,
    "isVersion": false,
    "isProxy": false,
    "changeToken": "1504185958567",
    "title": "The new document",
    "lastModified": "2017-08-31T13:25:58.567Z",
    "facets": [
        "Versionable",
        "Publishable",
        "Commentable",
        "HasRelatedText",
        "Downloadable"
    ]
}

Note dfc52762-a3dd-43df-9a8a-deebfec8a0ee is the id of my Root document.

0 votes



Hi Kevin ! Thank you for your reply. I repeat the test with your example :

POST http://localhost:8080/nuxeo/api/v1/id/094a6c81-891c-4a0f-9eec-8dbde7fdb85d {

"entity-type": "document",
"name":"newNewDoc",
"type": "File",
"properties": {
    "dc:title": "The new document",
    "dc:description": "Created via a very cool and easy REST API",
    "common:icon": "/icons/file.gif",
    "common:icon-expanded": null,
    "common:size": null
}

}

But I get the same error : 500 exception – “invalid argument exception. No doc type specified” as Response. How to resolve this issue . I don't understand what is the problem!

-1 votes



Which body type do you use ? Which http headers do you provide ?
08/31/2017

form-data for the body type. for the http I used http://localhost:8080/nuxeo/api/v1/id/094a6c81-891c-4a0f-9eec-8dbde7fdb85d.
08/31/2017

You can use raw with Content-Type application/json
08/31/2017

it works well!! thank you Kevin :-)
09/04/2017