Jasper 服务器 rest_v2 上传文件要求额外参数

Jasper server rest_v2 to upload file asking for extra parameters

使用 TIBCO JasperReports Server 6.3.0 并通过 rest_v2 端点添加资源。 resource descriptor for file 看起来很简单,这是我用来测试它的脚本:

#!/bin/bash
output=$(curl -sX POST "http://localhost:8080/jasperserver/rest_v2/resources/common/someFile.jrtx?createFolders=true" \
         -H "Content-Type:application/repository.query+json" \
         -H "Accept:application/json" \
         -d "{
            \"uri\" :\"/common/someFile.jrtx\",
            \"label\":\"someFile.jrtx\",
            \"description\":\"Some File\",
            \"permissionMask\":\"0\",
            \"type\":\"jrtx\",
            \"content\":\"$(base64 -w 0 /path/to/someFile.jrtx)\"
         }"  \
         --user jasperadmin:jasperadmin)

echo "${output}" | python -m json.tool

我得到的结果令人费解:

[
    {
        "errorCode": "mandatory.parameter.error",
        "message": "A value for the field QueryValue must be set",
        "parameters": [
            "QueryValue"
        ]
    },
    {
        "errorCode": "mandatory.parameter.error",
        "message": "A value for the field Language must be set",
        "parameters": [
            "Language"
        ]
    }
]

FILE 的描述符没有提到这些字段(语言或查询值)中的任何一个,我当然不必在手动创建文件时输入它们。我做错了什么?

JRTX 文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperTemplate PUBLIC "-//JasperReports//DTD Template//EN" "http://jasperreports.sourceforge.net/dtds/jaspertemplate.dtd">

<jasperTemplate>
   <style name="SimpleStyle"/>
   <style name="ColumnHeading" hAlign="Center" vAlign="Middle" isBlankWhenNull="true" fontName="Verdana" fontSize="10" isBold="true">
      <pen lineWidth="1.0" lineColor="#666565"/>
      <box>
         <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
         <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
         <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
         <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
      </box>
   </style>
   <style name="Title" markup="" fontSize="20" isBold="true"/>
   <style name="TableCells" hAlign="Center" vAlign="Middle" isBlankWhenNull="true" fontName="Verdana" fontSize="10" isBold="false">
      <pen lineWidth="1.0" lineColor="#CCCCCC"/>
      <box>
         <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#CCCCCC"/>
         <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#CCCCCC"/>
         <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#CCCCCC"/>
         <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#CCCCCC"/>
      </box>
   </style>
   <style name="VerticalColumnHeading" hAlign="Center" vAlign="Middle" rotation="Left" fontName="Verdana" fontSize="12" isBold="true"/>
   <style name="GroupHeading" hAlign="Left" vAlign="Middle" fontName="Verdana" fontSize="10">
      <pen lineWidth="1.0" lineColor="#CCCCCC"/>
   </style>
</jasperTemplate>

错误的内容类型。而不是这个

-H "Content-Type:application/repository.query+json" \

我应该使用这个:

-H "Content-Type:application/repository.file+json" \