bmservices Posted January 29, 2018 Share Posted January 29, 2018 Hi together,I 'd like to automatically deploy an Jasper-Report on a server after creating a jrxml from a database table.Tested first: manual deployment of jrxml works fine.There is an existing folder on the server:Reports/VK/DF/SP/dashboard/export/mquestSo I'm sending a POST request to:https://<server>/jasperserver/rest_v2/ressources/Reports/VK/DF/SP/dashboard/export/mquestwith the Headers:Content-Type: application/repository.reportUnit+jsonAccept: application/jsonAuthorization: Bearer ...In the POST body something like:{ "label":"mquest_P706_SEG_Rackjobbing", "dataSource" : { "dataSourceReference" : { "uri" : "/Data Sources/Vertikom Datawarehouse PRO" } }, "jrxml" : { "jrxmlFile" : { "type":"jrxml", "label": "mquest_P706_SEG_Rackjobbing", "content" : "..." } }}In content the base64 encoded jrxml file.I always get a 404 error. Why? Is the URL malformed?Changing Authorization Bearer to something else ends in "unauthorzied". That's ok. Thanks für any help, Bernd Link to comment Share on other sites More sharing options...
joseng62 Posted January 30, 2018 Share Posted January 30, 2018 Hi Rest api can get so frustrating so I could understand how you feel by now. So the 404 could mean a couple of things. Best would be the test your rest call in a program like postman or R client, jasperserver in most cases sends back error response. Examples<errorCode>resource.already.exists</errorCode>orWhen using your datasource "/Data Sources/Vertikom Datawarehouse PRO" the below error. I notice your datasource name has whitespaces, you need to call the resource id . In jasperserver the resource ID cannot have white spaces. The resource id is not the same as the label, unless your kept it the same onpurpose. If not your resource id name will most likely be Vertikom_Datawarehouse_PRO<errorCode>illegal.parameter.value.error</errorCode><message>The value "/Data Sources/Vertikom Datawarehouse PRO" for parameter "resourceReference.uri" is invalid.</message>Ok some more feedback. I succesfully completed your rest request by using aPUT and having the following values. (So your json paylod structure seems to be fine.)url : http://localhost:8080/jasperserver/rest_v2/resources/jasperrepopathtoreport/TestReport?createFolders=true&overwrite=trueHeadersX-REMOTE-DOMAIN : 1Content-Type : application/repository.reportUnit+jsonBody : { "label":"mquest_P706_SEG_Rackjobbing", "dataSource" : { "dataSourceReference" : { "uri" : "/path/to/datasources/resourceIofdatasource" } }, "jrxml" : { "jrxmlFile" : { "type":"jrxml", "label": "mquest_P706_SEG_Rackjobbing", "content" : "my own 64 encode report" } }} Link to comment Share on other sites More sharing options...
bmservices Posted January 30, 2018 Author Share Posted January 30, 2018 Thx for the suggestions.Finally I managed it.I changed my data source to the id. So my request body looks like: "label":"mquest_P706_SEG_Rackjobbing", "dataSource" : { "dataSourceReference" : { "uri" : "/Data_Sources/Vertikom_Datawarehouse_PRO" } }, "jrxml" : { "jrxmlFile" : { "type":"jrxml", "label": "mquest_P706_SEG_Rackjobbing", "content" : "..." } }} And I tried to send a PUT request to:https://<server>/jasperserver/rest_v2/resources/Reports/VK/DF/SP/dashboard/export/mquest/mquest_P706_SEG_Rackjobbing?createFolders=true&overwrite=trueMy error was "ressources" instead of "resources".Then I get 201 created. And the report is working. Regards, Bernd Link to comment Share on other sites More sharing options...
joseng62 Posted January 31, 2018 Share Posted January 31, 2018 Hi bmservices, Glad you could solve your issues. Could you upvote my answer, pls. Thanks 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