How to create/update a document in the API Playground using POST/PUT?

Hi,

The question is in the title.

I keep getting a 404 error whenever I try to POST a new dummy document. I even tried using a generated 'body' template of a document after doing a GET on a pre-generated document.

Can someone share a working input for these operations??

Here's my failed input on the API:

repoID : default

document : { “entity-type”: “document”, “repository”: “default”, “uid”: “cd3eb986-efd5-404f-ae21-8e9da89cda01”, “path”: “/default-domain/UserWorkspaces/Administrator/Sputnik.txt”, “type”: “Note”, “state”: “project”, “parentRef”: “49ef8d01-9eb6-46ea-b537-adfafac05a27”, “isCheckedOut”: true, “changeToken”: “1428912399000”, “title”: “Sputnik.txt”, “lastModified”: “2015-04-13T08:06:39.00Z”, “properties”: {

"note:note": "python sputnik.py --command \"v8/shell.exe C:\\Users\\lboey\\Downloads\\edf-apt\\charte-edf-10\\scripts\\collection2.js\"",
"note:mime_type": "text/plain",
"uid:uid": null,
"uid:major_version": 0,
"uid:minor_version": 0,
"common:size": null,
"common:icon-expanded": null,
"common:icon": "/icons/note.gif",
"files:files": [],
"dc:description": null,
"dc:language": null,
"dc:coverage": null,
"dc:valid": null,
"dc:creator": "Administrator",
"dc:modified": "2015-04-13T08:06:39.00Z",
"dc:lastContributor": "Administrator",
"dc:format": null,
"dc:expired": null,
"dc:rights": null,
"dc:created": "2015-04-13T08:06:39.82Z",
"dc:title": "Sputnik.txt",
"dc:issued": null,
"dc:nature": null,
"dc:subjects": [],
"dc:contributors": [
  "Administrator"
],
"dc:source": null,
"dc:publisher": null,
"relatedtext:relatedtextresources": []

}, “facets”: [

"Versionable",
"Publishable",
"Commentable",
"HasRelatedText"

] }

Thanks!!

0 votes

1 answers

1435 views

ANSWER



Hi,

POST your request as below.

**URL:** http://{server}:{port}/nuxeo/site/api/v1/id/{workspaceID}``

WorkspaceID is the ID of the folder or workspace where u can place the created file.

Body:

{
  "entity-type": "document",
  "type": "File",
  "name": "myDocumentName",
  "properties": {
    "dc:title": "My Document Title"
}

Hope this helps you. Go through https://doc.nuxeo.com/display/NXDOC/REST+API+Entity+Types#document for more info.

0 votes