tonyy Posted March 27, 2014 Share Posted March 27, 2014 I have followed the guide, the approach which say works for datasource resource results in 400 bad request for reportUnit. Request Header: tried: application/xmltried: multipart/form-data Request URI:http://172.16.4.66:8080/jasperserver/rest/resource/reports/CustomersReport Request Type: POST Request Body:(just a copy of the reportUnit descriptor returned by get)<?xml version="1.0" standalone="no"?><resourceDescriptor name="CustomersReport" wsType="reportUnit" uriString="/reports/CustomersReport" isNew="false"> <label><![CDATA[Customers Report]]></label> <description><![CDATA[Customers Report]]></description> <creationDate>1395671859144</creationDate> <resourceProperty name="PROP_RESOURCE_TYPE"> <value><![CDATA[com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.ReportUnit]]></value> </resourceProperty> <resourceProperty name="PROP_PARENT_FOLDER"> <value><![CDATA[/reports]]></value> </resourceProperty> <resourceProperty name="PROP_VERSION"> <value><![CDATA[3]]></value> </resourceProperty> <resourceProperty name="PROP_SECURITY_PERMISSION_MASK"> <value><![CDATA[31]]></value> </resourceProperty> <resourceProperty name="PROP_RU_ALWAYS_PROPMT_CONTROLS"> <value><![CDATA[false]]></value> </resourceProperty> <resourceProperty name="PROP_RU_CONTROLS_LAYOUT"> <value><![CDATA[1]]></value> </resourceProperty> <resourceDescriptor wsType="datasource" isNew="false"> <resourceProperty name="PROP_REFERENCE_URI"> <value><![CDATA[/datasources/JServerJdbcDsS2]]></value> </resourceProperty> <resourceProperty name="PROP_IS_REFERENCE"> <value><![CDATA[true]]></value> </resourceProperty> </resourceDescriptor> <resourceDescriptor name="CustomersReport" wsType="jrxml" uriString="/reports/CustomersReport_files/CustomersReport" isNew="false"> <label><![CDATA[Customers Report]]></label> <description><![CDATA[Customers Report]]></description> <creationDate>1395671859144</creationDate> <resourceProperty name="PROP_RESOURCE_TYPE"> <value><![CDATA[com.jaspersoft.jasperserver.api.metadata.common.domain.FileResource]]></value> </resourceProperty> <resourceProperty name="PROP_PARENT_FOLDER"> <value><![CDATA[/reports/CustomersReport_files]]></value> </resourceProperty> <resourceProperty name="PROP_VERSION"> <value><![CDATA[0]]></value> </resourceProperty> <resourceProperty name="PROP_SECURITY_PERMISSION_MASK"> <value><![CDATA[31]]></value> </resourceProperty> <resourceProperty name="PROP_IS_REFERENCE"> <value><![CDATA[false]]></value> </resourceProperty> <resourceProperty name="PROP_HAS_DATA"> <value><![CDATA[true]]></value> </resourceProperty> <resourceProperty name="PROP_ATTACHMENT_ID"> <value><![CDATA[attachment]]></value> </resourceProperty> <resourceProperty name="PROP_RU_IS_MAIN_REPORT"> <value><![CDATA[true]]></value> </resourceProperty> </resourceDescriptor> <resourceDescriptor name="OrdersReport" wsType="jrxml" uriString="/reports/CustomersReport_files/OrdersReport" isNew="false"> <label><![CDATA[OrdersReport]]></label> <description><![CDATA[OrdersReport]]></description> <creationDate>1395671859144</creationDate> <resourceProperty name="PROP_RESOURCE_TYPE"> <value><![CDATA[com.jaspersoft.jasperserver.api.metadata.common.domain.FileResource]]></value> </resourceProperty> <resourceProperty name="PROP_PARENT_FOLDER"> <value><![CDATA[/reports/CustomersReport_files]]></value> </resourceProperty> <resourceProperty name="PROP_VERSION"> <value><![CDATA[0]]></value> </resourceProperty> <resourceProperty name="PROP_SECURITY_PERMISSION_MASK"> <value><![CDATA[31]]></value> </resourceProperty> <resourceProperty name="PROP_IS_REFERENCE"> <value><![CDATA[false]]></value> </resourceProperty> <resourceProperty name="PROP_HAS_DATA"> <value><![CDATA[true]]></value> </resourceProperty> <resourceProperty name="PROP_ATTACHMENT_ID"> <value><![CDATA[attachment]]></value> </resourceProperty> </resourceDescriptor></resourceDescriptor> Link to comment Share on other sites More sharing options...
pdanyliuk Posted March 27, 2014 Share Posted March 27, 2014 Hello tonyy,I'm not very familiar with REST v1, so I cannot provide much help there. But FYI, REST v1 services (/rest/*) are discontinued and replaced with newer and better REST v2 services (/rest_v2/*). If you have JRS 5.5 or later, then you can use REST v2 Repository service to create/edit your report units — that should be easier, and besides both XML and JSON are supported. You can find information on that in JRS Web Services guide here: http://community.jaspersoft.com/documentation/jasperreports-server-web-services-guide/v550/v2resources-servicePlease let me know if you can use RESTv2 and if you have any troubles using it.With best regards,Paul Danyliuk Link to comment Share on other sites More sharing options...
tonyy Posted March 27, 2014 Author Share Posted March 27, 2014 Can you please provide an http example with v2 pls? Thanks! Link to comment Share on other sites More sharing options...
pdanyliuk Posted March 27, 2014 Share Posted March 27, 2014 With your report link, try this for illustrative purposes GET http://172.16.4.66:8080/jasperserver/rest_v2/resources/reports/CustomersReport Accept: application/repository.reportUnit+json or +xml should return report unit descriptor with all dependencies (JRXML, Data Source etc) returned as references. In obtained data change label and description and send it in PUT request to the same URL with the following mandatory header: Content-Type: application/repository.reportUnit+json or +xml Accept: the same as previously, or simply application/json or /xml Creating a resource can be done with the same descriptor either by PUTting it at arbitrary URI (e.g. PUT http://172.16.4.66:8080/jasperserver/rest_v2/resources/reports/MyNewReport) or POSTing to a parent folder (e.g. POST http://172.16.4.66:8080/jasperserver/rest_v2/resources/reports) - in this case resource ID will be generated out of its label. You can also try to GET your report with parameter expanded=true: GET http://172.16.4.66:8080/jasperserver/rest_v2/resources/reports/CustomersReport?expanded=true in this case it will resolve all referenced resources recursively. If this works for you, I encourage you to learn RESTv2/Repository service to grasp the concepts behind it. Report Unit is a composite resource (contains own metadata PLUS references to other local or external resources), so for learning you can start with something simpler like JDBC Data Source. Link to comment Share on other sites More sharing options...
tonyy Posted March 28, 2014 Author Share Posted March 28, 2014 works well, though could not do partial update(without loading complete descriptor) via PATCH(say want to patch data source). Frankly new API doc is much worse while the API itself is marvellous - reverse and irony lol Link to comment Share on other sites More sharing options...
pdanyliuk Posted March 28, 2014 Share Posted March 28, 2014 There are a few things to know about PATCH: - to patch a resource, you have to provide the field "version", which has to be current (it's an optimistic locking mechanism that prevents from overwriting someone else's changes that were made while you were operating on it). The same for updating via PUT, so to say. - IIRC you cannot patch inner resources from outer resources. So if you want to patch a data source of report, you have to patch it directly by its URI (regardless if local or external). - you don't have to send all sub-resources in a PUT request when updating only the base resource - just provide the references how you GET'ed them, so if that was your concern about PUT vs PATCH - there is no such problem, and you don't have to use PATCH. While I agree that the documentation might be not very clear and obvious to follow, it should contain all information about the service (I personally checked that nothing was missing or inaccurate in a working draft doc - not sure how much of it made it to the final doc). The only complexity comes from variety of resources, but the principles are simple and the same for this service and most of the rest of RESTv2 API. Also if you are using Java or PHP, check out the official clients: https://github.com/Jaspersoft PHP client is not stable yet, having some issues with composite resources that will be fixed soon, but for everything else you can use it. Link to comment Share on other sites More sharing options...
rajesh.majoju Posted May 20, 2014 Share Posted May 20, 2014 Man can you please tell me how can i start v2 using java. Explain step by step if possible. 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