Search code examples
restjasper-reportsputjasperserver

Jasper webservice: Invalid resource descriptor


I try to upload a simple image via REST webservice to the jasper server.

This is the HTTP request/response, I'm getting "400 Bad Request: Invalid resource descriptor". I tried to copy a valid resource descriptor from the repository and re-upload it but it gives the same error!

(The dots represent \r\n and \t chars.)

T 10.84.6.166:36057 -> 10.84.6.166:8080 [AP].
PUT /jasperserver/rest/resource/reports/Customers/3221/image01.gif HTTP/1.1.
User-Agent: useragent.
Host: 10.84.6.166:8080.
Accept: */*.
Cookie: JSESSIONID=5D8D24835E61ED65ABD982964243C06B.
Content-Type: multipart/form-data; boundary="72e01e9922f8bb1669638258c2a2a155".
Content-Length: 23796.
Expect: 100-continue.
.


T 10.84.6.166:8080 -> 10.84.6.166:36057 [AP]
HTTP/1.1 100 Continue.
.


T 10.84.6.166:36057 -> 10.84.6.166:8080 [AP]
--72e01e9922f8bb1669638258c2a2a155.
Content-Disposition: form-data; name="ResourceDescriptor".
Content-Length: 811.
Content-Type: text/plain; charset=UTF-8.
Content-Transfer-Encoding: 8bit.
.
<resourceDescriptor name="s2" wsType="img" uriString="/reports/Customers/3221/s2.png" isNew="true">.
.<label><![CDATA[serverattacks_13-06-01.png]]></label>.
.<creationDate>1373470272965</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/Customers/3221]]></value>.
.</resourceProperty>.
.<resourceProperty name="PROP_VERSION">.
..<value><![CDATA[0]]></value>.
.</resourceProperty>.
.<resourceProperty name="PROP_HAS_DATA">.
..<value><![CDATA[true]]></value>.
.</resourceProperty>.
.<resourceProperty name="PROP_IS_REFERENCE">.
..<value><![CDATA[false]]></value>.
.</resourceProperty>.
</resourceDescriptor>.
--72e01e9922f8bb1669638258c2a2a155.
Content-Disposition: form-data; name="/reports/Customers/3221/s2.png".
Content-Length: 22544.
Content-Type: application/octet-stream.
Content-Transfer-Encoding: binary.
.
<long binary png contents>
--72e01e9922f8bb1669638258c2a2a155--.


T 10.84.6.166:8080 -> 10.84.6.166:36057 [AP]
HTTP/1.1 400 Bad Request.
Server: Apache-Coyote/1.1.
Pragma: No-cache.
Cache-Control: no-cache.
Expires: Thu, 01 Jan 1970 01:00:00 CET.
P3P: CP="ALL".
Content-Type: text/xml;charset=UTF-8.
Content-Length: 27.
Date: Thu, 11 Jul 2013 08:42:09 GMT.
Connection: close.
.
Invalid resource descriptor

Update:

I still don't know what's wrong but I finally got it working and released a Jasper PHP Library on github: http://blog.flowl.info/2013/jasper-php-library-on-github/


Solution

  • I tried to update jrxml on jasperServer. I found and buld java tests. I found working example of updating image on JasperServer.Mаy it is help уou.(With help of this example i wrote request for updating jrxml on jasperServer. And it is works!)

        POST http://repsuite.cheby.ru:8080/jasperserver/rest/resource/SAMPLE_REST_FOLDER/JUNIT_IMAGE_FILE HTTP/1.1
    Content-Length: 5560
    Content-Type: multipart/form-data; boundary=dzFSpJmyJB0pL6bHxKgtqI4VmaKgL9pTWCrLeJv
    Host: repsuite.cheby.ru:8080
    Connection: Keep-Alive
    User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
    Cookie: JSESSIONID=E485652B97C69549403D8CEEA0DC0855
    Cookie2: $Version=1
    
    --dzFSpJmyJB0pL6bHxKgtqI4VmaKgL9pTWCrLeJv
    Content-Disposition: form-data; name="ResourceDescriptor"
    
    <resourceDescriptor name="JUNIT_IMAGE_FILE" wsType="img" uriString="/SAMPLE_REST_FOLDER/JUNIT_IMAGE_FILE" isNew="true">
        <label>jaspersoft logo</label>
        <description>jaspersoft logo</description>
        <creationDate>1308696383000</creationDate>
        <resourceProperty name="PROP_RESOURCE_TYPE">
            <value>com.jaspersoft.jasperserver.api.metadata.common.domain.FileResource</value>
        </resourceProperty>
        <resourceProperty name="PROP_PARENT_FOLDER">
            <value>/SAMPLE_REST_FOLDER</value>
        </resourceProperty>
        <resourceProperty name="PROP_VERSION">
            <value>0</value>
        </resourceProperty>
        <resourceProperty name="PROP_IS_REFERENCE">
            <value>false</value>
        </resourceProperty>
        <resourceProperty name="PROP_HAS_DATA">
            <value>true</value>
        </resourceProperty>
    </resourceDescriptor>
    --dzFSpJmyJB0pL6bHxKgtqI4VmaKgL9pTWCrLeJv
    Content-Disposition: form-data; name="/SAMPLE_REST_FOLDER/JUNIT_IMAGE_FILE"; filename="jasperSoftLogo_2.jpg"
    Content-Type: application/octet-stream
    

    ----Binary content of image----