Jump to content
We've recently updated our Privacy Statement, available here ×

Deploying a report ends in 404 error


bmservices

Recommended Posts

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/mquest

So I'm sending a POST request to:

https://<server>/jasperserver/rest_v2/ressources/Reports/VK/DF/SP/dashboard/export/mquest

with the Headers:

Content-Type: application/repository.reportUnit+json
Accept: application/json
Authorization: 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

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

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>
or
When 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 a
PUT 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=true
Headers
X-REMOTE-DOMAIN : 1
Content-Type : application/repository.reportUnit+json

Body : 

{
  "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

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=true

My 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...