spierepf Posted June 14, 2012 Share Posted June 14, 2012 Greetings,I am trying to create a folder in the JRS repository using the REST service. I am using Ruby and the rest-client library to connect.So far, I've managed to read stuff from the repository, but I haven't had much luck with altering the repository contents.My test case is to create two folders at the root of the repository. A parent folder at /parent, and a child folder at /parent/child. Here is the resource descriptor of the parent folder.<resourceDescriptor name="parent" wsType="folder" uriString="/parent"> <label>REST created folder</label> <resourceProperty name="PROP_PARENT_FOLDER"> <value>/</value> </resourceProperty></resourceDescriptor>No matter what I try, I get an error 400 BadRequest, with a 'Invalid resource descriptor' message.Has anyone had any success with creating folders?Peter. Link to comment Share on other sites More sharing options...
spierepf Posted June 14, 2012 Author Share Posted June 14, 2012 I've installed TcpMon and captured the request:PUT /report/rest/resource/ HTTP/1.1Content-Type: multipart/form-data; boundary=32032Accept: */*; q=0.5, application/xmlAccept-Encoding: gzip, deflateHost: localhost:8080Content-Length: 315Authorization: Basic c3VwZXJ1c2VyOnN1cGVydXNlcg==--32032Content-Disposition: form-data; name="ResourceDescriptor"<resourceDescriptor name="parent" wsType="folder" uriString="/parent" isNew="true"> <label>REST created folder</label> <resourceProperty name="PROP_PARENT_FOLDER"> <value>/</value> </resourceProperty></resourceDescriptor>--32032--and the response: HTTP/1.1 400 Bad RequestServer: Apache-Coyote/1.1Cache-Control: privateExpires: Wed, 31 Dec 1969 20:00:00 ASTSet-Cookie: JSESSIONID=CC3CE809E753F21931A3558DEFCE5B90; Path=/report/; HttpOnlyContent-Type: text/xml;charset=UTF-8Content-Length: 27Date: Wed, 13 Jun 2012 20:56:47 GMTConnection: closeInvalid resource descriptor Link to comment Share on other sites More sharing options...
rossi_jeff Posted September 11, 2012 Share Posted September 11, 2012 Did you get this working? I'm having the same issue. Link to comment Share on other sites More sharing options...
rossi_jeff Posted September 11, 2012 Share Posted September 11, 2012 I'm using multipart-post gem in a rails 3 app opening connection to reports.intouchgps.com...opened<- "PUT /jasperserver/rest/resource HTTP/1.1\r\nAccept: */*\r\nUser-Agent: Ruby\r\nContent-Type: multipart/form-data; boundary=-----------RubyMultipartPost\r\nContent-Length: 457\r\nAuthorization: Basic d2Vic2VydmljZXM6d2Vic2VydmljZXM=\r\nConnection: close\r\nHost: reports.intouchgps.com:8080\r\n\r\n"<- "-------------RubyMultipartPost\r\nContent-Disposition: form-data; name=\"ResourceDescriptor\"\r\n\r\n<resourceDescriptor name=\"75a425c0-de74-012f-d7d6-38ac6fdf26f8\" wsType=\"folder\" uriString=\"/Scheduled/75a425c0-de74-012f-d7d6-38ac6fdf26f8\" isNew=\"false\"><label>User Folder 75a425c0-de74-012f-d7d6-38ac6fdf26f8</label><resourceProperty name=\"PROP_PARENT_FOLDER\"><value>/Scheduled</value></resourceProperty></resourceDescriptor>\r\n-------------RubyMultipartPost--\r\n\r\n"-> "HTTP/1.1 400 Bad Request\r\n"-> "Server: Apache-Coyote/1.1\r\n"-> "Pragma: No-cache\r\n"-> "Cache-Control: no-cache\r\n"-> "Expires: Wed, 31 Dec 1969 16:00:00 PST\r\n"-> "P3P: CP=\"ALL\"\r\n"-> "Set-Cookie: JSESSIONID=BE57A2C851D02CB1CB448052D9246DB3; Path=/jasperserver\r\n"-> "Content-Type: text/xml;charset=UTF-8\r\n"-> "Content-Length: 27\r\n"-> "Date: Tue, 11 Sep 2012 20:14:48 GMT\r\n"-> "Connection: close\r\n"-> "\r\n"reading 27 bytes...-> "Invalid resource descriptor"read 27 bytesConn close This was in the log 2012-09-11 12:45:48,673 DEBUG RESTServlet,http-8080-7:131 - request params: Path: /resource Requested Service: resource Service from registry: class com.jaspersoft.jasperserver.rest.services.RESTResource$$EnhancerByCGLIB$$79dc9457 2012-09-11 12:45:48,676 DEBUG RESTAbstractService,http-8080-7:100 - execute: Resource=/resource Method=put 2012-09-11 12:45:48,815 DEBUG Utils,http-8080-7:158 - 0 attachments were extracted from the POST 2012-09-11 12:45:48,817 ERROR RESTResource,http-8080-7:237 - Unexpected error during resource descriptor marshaling: Premature end of file. org.xml.sax.SAXParseException: Premature end of file. Link to comment Share on other sites More sharing options...
rossi_jeff Posted September 13, 2012 Share Posted September 13, 2012 By putting the xml as the body of the put request I got a folder created, but it returned an empty document code 201 instead of the xml resource descriptor it says I should receive in the manual. Link to comment Share on other sites More sharing options...
bschundawat143 Posted June 27, 2013 Share Posted June 27, 2013 Hi Rossi, Can you please let me know the procedure how you are creating a folder. Thanks! Link to comment Share on other sites More sharing options...
sam.sabbaghpromontech.com Posted February 26, 2019 Share Posted February 26, 2019 For anyone still trying to do this, here is an example that worked for me. Creating the folder "Reports" under myorg locally.Using PUTurl = 'http://localhost:8080/jasperserver-pro/rest_v2/resources/organizations/myorg/Reports'headers = {'Content-Type': 'application/repository.folder+json'}content = {"uri" :"/organizations/myorg/Reports", "label":"Reports", "description":"Create and save your own reports here.", "permissionMask":"0", "creationDate": "2013-07-04T12:18:47", "updateDate": "2013-07-04T12:18:47", "version":"0"} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now