Hello,
I try to write a REST Applikation in Java with Jersey 1.17 that use the ContentServer Api v.1. I can "Authenticate" via the POST Method, I can GET a Node or create a new Node via the "Node" Post Method, but if I want to create a new version in a node, I got a 400 Response Status Code and the following Error: {"error":"Could not process object, type \u0027Folder\u0027 has no role \u0027versions\u0027"}.
This is what i exactly want to do:
In my Content Server is a Node with the Name "Test" and the ID "26638" there are no Documents/Versions in the Folder. In the Next Step I want to create a new Version/Document via Jersey.
I use following URL: http://localhost/OTCS/cs.exe/api/v1/nodes/26638/versions
Then I run the Unit Test for Creating a "Node" which is successful.
Then I run the Unit Test for creating a Version see following Source Code:
//===========================================================================
// Version - Post
//===========================================================================
public static Versions postVersions(AuthenticationTicketDto authenticationTicket, String versionID){
logger.info("**** postVersion ****");
final FormDataMultiPart formDataMultiPart = new FormDataMultiPart();
final String value ="Hello World";
final FormDataContentDisposition dispo = FormDataContentDisposition
.name("file")
.fileName("test.txt")
.size(value.getBytes().length)
.build();
final FormDataBodyPart bodyPart = new FormDataBodyPart(dispo, value, MediaType.MULTIPART_FORM_DATA_TYPE);
formDataMultiPart.bodyPart(bodyPart);
ClientResponse response = CSClient.getInstance()
.path("nodes/" + versionID + "/versions")
.accept(MediaType.APPLICATION_JSON_TYPE)
.entity(formDataMultiPart, MediaType.MULTIPART_FORM_DATA_TYPE)
.header(CSClientConstants.OTCS_TICKET, authenticationTicket.getTicket())
.post(ClientResponse.class, formDataMultiPart);
logger.info("Response Statuscode of postVersion() Request.: " + response.getStatus());
return response.getEntity(Versions.class);
}
@Test
public void A_CreateVersionInContentServer() {
logger.info("*************** Test Creating/Posting NODE ***************");
Versions versions = CSClientVersion.postVersions(authenticationTicket, "26638");
assertNotNull(versions);
}
The JUnit TestCase gives me an exception: with 400 Statuscode.
I also turned on Jersey logging so I can see the HTTP Requests and the HTTP Response:
HTTP - Request - triggered from JUnit Testcase:
==============================================
Hello World
--Boundary_1_580554322_1402417619923--
Client out-bound request
POST http://localhost/OTCS/cs.exe/api/v1/nodes/26638/versions
Content-Type: multipart/form-data
OTCSTICKET: +6XXX4Pm/5xmY5euqlSZuVFpdV10pzO0jP6ciKvZK5SxcJwCgY3PK+bAmRppw6h1
--Boundary_1_580554322_1402417619923
Content-Type: multipart/form-data
Content-Disposition: form-data; filename="test.txt"; size=11; name="file"
HTTP - Response - triggered from JUnit Testcase:
==============================================
{"error":"Could not process object, type \u0027Folder\u0027 has no role \u0027versions\u0027"}
Client in-bound response
400
Date: Tue, 10 Jun 2014 16:26:59 GMT
Content-Length: 94
OTCSTicket: +6XXX4Pm/5xmY5euqlSZuVFpdV10pzO0jP6ciKvZK5SxcJwCgY3PK+bAmRppw6h1
Expires: 0
Content-Type: application/json; charset=UTF-8
X-Powered-By: ASP.NET
Server: Microsoft-IIS/7.5
Pragma: no-cache
Cache-Control: no-cache, no-store, must-revalidate, max-age=0
I also implemented a Jersey WebService with Multipart functionality by myself, and run a JUnit Test to test my own client side code, but everything works fine.
I also tried to create a new Version via Postman but I got the same Statuscode and the same Error Message.
What's wrong ?