2

I am using alfresco 5.2 as CMS. I am using autoRename property for the content creation like below(Dummy).

    {
        "name":"xyz.pdf",
        "nodeType":"cm:content",
        "relativePath":"X/Y/Z",
        "autoRename":true
    }

I get this from below link. I post this Json

[{ "name":"yoB4004-RA.pdf","nodeType":"cm:content","relativePath":"1","autoRename":true,"properties":{"cm:title":"yoB4004-RA.pdf","cm:description":"yoB4004-RA.pdf"}},{ "name":"yoB4004-RA2.pdf","nodeType":"cm:content","relativePath":"1","autoRename":true,"properties":{"cm:title":"yoB4004-RA2.pdf","cm:description":"yoB4004-RA2.pdf"}}]

But getting this error

ResponseContentUtil [isSuccess=false, statusCode=400, responseMessage={"error":{"errorKey":"Could not read content from HTTP request body: Unrecognized field \"autoRename\" (Class org.alfresco.rest.api.model.Node), not marked as ignorable\n at [Source: java.io.BufferedReader@13f456b5; line: 1, column: 88] (through reference chain: org.alfresco.rest.api.model.Node[\"autoRename\"])","statusCode":400,"briefSummary":"03280036 Could not read content from HTTP request body: Unrecognized field \"autoRename\" (Class org.alfresco.rest.api.model.Node), not marked as ignorable\n at [Source: java.io.BufferedReader@13f456b5; line: 1, column: 88] (through reference chain: org.alfresco.rest.api.model.Node[\"autoRename\"])","stackTrace":"For security reasons the stack trace is no longer displayed, but the property is kept for previous versions","descriptionURL":"https://api-explorer.alfresco.com"}}]

This post work without autoRename property

1 Answers1

1

'autoRename' is a part of query and you are trying to pass it in the JSON body. Ideally, your request URL should be like the following

http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-my-/children?autoRename=true

you should pass the JSON without

"autoRename":true

and append it at the end of the URL, as mentioned in the above URL

Kintu Barot
  • 320
  • 2
  • 11
  • Thanks @Kintu it solves my problem. But another problem occurs that first, I create children node that creates the blank files with node id then I compare my post file name with response file name then post input stream on that node id. But it fails in this scenario because of file name change in duplicate case. And no direct way found to upload files on parent folder node id. So please help me – Dhirendra Sharma May 02 '18 at 14:00
  • Please, let me know, how do you add the content (input stream) to a node. – Kintu Barot May 03 '18 at 04:33
  • I got node id with the file name in response from above post then I get node id of the file by matching file name in a loop then i post on url `http://localhost:8280/alfresco/api/-default-/public/alfresco/versions/1/nodes/dff02aef-10c6-4268-9e38-378be9d9fa38/content` with below that contains input stream `public class RequestDetails { RequestHeaders requestHeader = new RequestHeaders(); RequestParameters requestParameter = new RequestParameters(); String requestContent ; InputStream streamContent ; //Set this for streams // Getter Setter below ..}` – Dhirendra Sharma May 03 '18 at 06:09
  • Is there any way to upload a file in one post, not like (First create child node then post content on that child node id).. ? – Dhirendra Sharma May 03 '18 at 06:14
  • For that, you can create your own web script in Alfresco or you can use CMIS. – Kintu Barot May 03 '18 at 14:10